hal.internet package

Submodules

hal.internet.engines module

Abstract search engines

class hal.internet.engines.SearchEngine(url, blank_replace='+')[source]

Bases: object

Internet general search engine

get_search_page(query)[source]

Gets HTML source

Parameters:query – query to search engine
Returns:HTML source of search page of given query
parse_query(query)[source]

Parses given query in order to meet search criteria of search engine

Parameters:query – Query to search engine
Returns:query of search engine (well-formatted)
class hal.internet.engines.SearchEngineResult(title, link, description='')[source]

Bases: object

Result of general search engine

hal.internet.parser module

hal.internet.utils module

Internet tools

hal.internet.utils.add_params_to_url(url, params)[source]

Adds params to url

Parameters:
  • url – Url
  • params – Params to add
Returns:

original url with new params

hal.internet.utils.get_my_external_ip()[source]

Gets external IP

Returns:external IP
hal.internet.utils.is_internet_on(host='8.8.8.8', port=53, timeout=3)[source]

Checks if machine has internet connection

Parameters:
  • host – hostname to test
  • port – port of hostname
  • timeout – seconds before discarding connection
Returns:

True iff machine has internet connection

hal.internet.utils.wait_until_internet(time_between_attempts=3, max_attempts=10)[source]

Waits until machine has internet

Parameters:
  • time_between_attempts – seconds between 2 consecutive attempts
  • max_attempts – max number of attempts to try
Returns:

True iff there is internet connection

hal.internet.web module

Deal with web-pages

class hal.internet.web.Webpage(url)[source]

Bases: object

Representation of Web page at URL

download_to_file(local_file, headers=None, cookies=None, chunk_size=1024)[source]

Downloads link to local file

Parameters:
  • local_file – Save url as this path
  • headers – Headers to fetch url
  • cookies – Cookies to fetch url
  • chunk_size – int
download_url(local_file)[source]

Downloads url to local file

Parameters:local_file – Save url as this path
get_domain()[source]

Gets domain of url :return: get domain from given url

get_hostname()[source]

Gets hostname of url :return: extract hostname from given url

get_html_source()[source]

Gets source page of url :return: HTML source

Gets links in page

Parameters:
  • recall – max times to attempt to fetch url
  • timeout – max times
Returns:

array of out_links

get_scheme()[source]

Gets scheme of url :return: get scheme (HTTP, HTTPS, FTP ..) from given url

open_in_browser(n_times)[source]

Opens page in browser

Parameters:n_times – Times to open page in browser
static parse_url(url)[source]

Parses correctly url

Parameters:url – url to parse
hal.internet.web.get_tor_session()[source]

Finds TOR session

Returns:TOR session
hal.internet.web.is_url(candidate)[source]

Checks if string is url

Parameters:candidate – url to check for url
Returns:True iff candidate is a valid url
hal.internet.web.renew_connection(password)[source]

Renews TOR session

Parameters:password – new password