ProxyGenerator module

exception scholarly._proxy_generator.DOSException[source]

DOS attack was detected.

class scholarly._proxy_generator.ProxyGenerator[source]

Sets up a proxy from the free-proxy library

Example::pg = ProxyGenerator() pg.FreeProxies()
Luminati(usr, passwd, proxy_port)[source]

Setups a luminati proxy without refreshing capabilities.

  • usr (string) – scholarly username, optional by default None
  • passwd (string) – scholarly password, optional by default None
  • proxy_port (integer) – port for the proxy,optional by default None

pg = ProxyGenerator() pg.Luminati(usr = foo, passwd = bar, port = 1200)


Sets up a proxy using ScraperAPI

Example::pg = ProxyGenerator() pg.ScraperAPI(API_KEY)
Parameters:API_KEY (string) – ScraperAPI API Key value.
SingleProxy(http=None, https=None)[source]

Use proxy of your choice :param http: http proxy address type http: string :param https: https proxy adress :type https: string

Example::pg = ProxyGenerator() pg.SingleProxy(http = <http proxy adress>, https = <https proxy adress>)
Tor_External(tor_sock_port: int, tor_control_port: int, tor_password: str)[source]

Setting up Tor Proxy. A tor service should be already running on the system. Otherwise you might want to use Tor_Internal

  • tor_sock_port (int) – the port where the Tor sock proxy is running
  • tor_control_port (int) – the port where the Tor control server is running
  • tor_password (str) – the password for the Tor control server

pg = ProxyGenerator() pg.Tor_External(tor_sock_port = 9050, tor_control_port = 9051, tor_password = “scholarly_password”)

Tor_Internal(tor_cmd=None, tor_sock_port=None, tor_control_port=None)[source]

Starts a Tor client running in a scholarly-specific port, together with a scholarly-specific control port. If no arguments are passed for the tor_sock_port and the tor_control_port they are automatically generated in the following ranges - tor_sock_port: (9000, 9500) - tor_control_port: (9500, 9999)

  • tor_cmd (string) – tor executable location (absolute path if its not exported in PATH)
  • tor_sock_port (int) – tor socket port
  • tor_control_port (int) – tor control port

pg = ProxyGenerator() pg.Tor_Internal(tor_cmd = ‘tor’)

get_next_proxy(num_tries=None, old_timeout=3)[source]
has_proxy() → bool[source]
class scholarly._proxy_generator.Singleton[source]