Created
November 13, 2020 20:31
-
-
Save andrewrgoss/430bd96201b13f7e034524acd48e9797 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # !/usr/bin/env python | |
| __author__ = 'agoss' | |
| import argparse | |
| import json | |
| import requests | |
| from scraper_api import ScraperAPIClient | |
| import sys | |
| def main(): | |
| parser = argparse.ArgumentParser(description='Parses command line arguments') | |
| parser.add_argument('--scraper_api_key', type=str, required=True) | |
| args = parser.parse_args() | |
| client = ScraperAPIClient(args.scraper_api_key) | |
| result = json.loads(client.get(url='http://httpbin.org/ip').text) | |
| print('Rotated proxy IP address = ' + result['origin']) | |
| urls = [ | |
| client.scrapyGet(url='http://quotes.toscrape.com/page/1/'), | |
| client.scrapyGet(url='http://quotes.toscrape.com/page/2/'), | |
| ] | |
| for url in urls: | |
| r = requests.get(url) | |
| # add parsing logic here | |
| print(r.status_code) | |
| try: | |
| main() | |
| except Exception as err: | |
| print(err) | |
| sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment