ProxyGenerator module

exception scholarly._proxy_generator.DOSException[source]

DOS attack was detected.

class scholarly._proxy_generator.ProxyGenerator[source]
FreeProxies()[source]

Sets up a proxy from the free-proxy library

Returns:whether or not the proxy was set up successfully
Return type:{bool}
Example::pg = ProxyGenerator() success = pg.FreeProxies()
Luminati(usr, passwd, proxy_port)[source]

Setups a luminati proxy without refreshing capabilities.

Parameters:
  • 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
Returns:

whether or not the proxy was set up successfully

Return type:

{bool}

Example::

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

ScraperAPI(API_KEY, country_code=None, premium=False, render=False)[source]

Sets up a proxy using ScraperAPI

The optional parameters are only for Business and Enterprise plans with ScraperAPI. For more details, https://www.scraperapi.com/documentation/

Example::pg = ProxyGenerator() success = pg.ScraperAPI(API_KEY)
Parameters:API_KEY (string) – ScraperAPI API Key value.
Returns:whether or not the proxy was set up successfully
Return type:{bool}
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 :returns: whether or not the proxy was set up successfully :rtype: {bool}

Example::pg = ProxyGenerator() success = 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

Parameters:
  • 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
Example::

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)

Parameters:
  • 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
Example::

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

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