Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified test suite to use Tor, to improve reliability #82

Closed
wants to merge 2 commits into from

Conversation

ipeirotis
Copy link
Collaborator

Modified test suite to use Tor as proxies for the requests against scholar.

Comment on lines +7 to +10
def setUp(self):
# Testing using Tor, as other proxies tend to be less reliable
proxies = {'http' : 'socks5://127.0.0.1:9050', 'https': 'socks5://127.0.0.1:9050'}
scholarly.use_proxy(**proxies)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if this could be made optional in case a Tor proxy isn't running. My naive approach below didn't work because of some weird exception handling going on in the requests module. If you can think of another way to achieve this, that would be great.

Suggested change
def setUp(self):
# Testing using Tor, as other proxies tend to be less reliable
proxies = {'http' : 'socks5://127.0.0.1:9050', 'https': 'socks5://127.0.0.1:9050'}
scholarly.use_proxy(**proxies)
proxy_flag = True
def setUp(self):
# Try testing using Tor, as other proxies tend to be less reliable
proxies = {'http' : 'socks5://127.0.0.1:9050', 'https':
'socks5://127.0.0.1:9050'}
if self.proxy_flag:
try:
scholarly.use_proxy(**proxies)
except Exception:
print("Tor proxy not working. Continuing without...")
self.proxy_flag = False

@ipeirotis
Copy link
Collaborator Author

Closing this. Tried to address the issues raised at #88

@ipeirotis ipeirotis closed this May 14, 2020
@ipeirotis ipeirotis deleted the test_using_proxies branch May 14, 2020 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants