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
| """ | |
| Scrap the full list of active vessels form MAERSK | |
| """ | |
| import asyncio | |
| import re | |
| import csv | |
| from typing import IO | |
| import requests | |
| from w3lib.url import add_or_replace_parameter |
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
| def fix_json_unescaped_quotes(json_str): | |
| """For example: | |
| "name":"Under Armour Women's On 3" Shorts" | |
| => | |
| "name":"Under Armour Women's On 3\" Shorts" | |
| """ | |
| new_json_str = '' | |
| is_open = False # When : is found in a declaration | |
| is_started = False # When " is found after : | |
| for j_ix, j_chr in enumerate(json_str): |
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
| # Custom blocking detection and retries with puppeteer API example | |
| import logging | |
| from functools import wraps | |
| logger = logging.getLogger(__name__) | |
| BLOCKED_CODES = [403, 500, 502, 503, 504] |
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 | |
| import urllib2 | |
| import json | |
| def check_envio(num_envio): | |
| url = 'http://www.enviosoca.com/Tracking/GetLastTrackingData/default.aspx?trackingNumber=%s' % (num_envio,) | |
| resp = urllib2.urlopen(url) | |
| json_data = resp.read() | |
| return json.loads(json_data) |
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
| # -*- coding: utf-8 -*- | |
| from scrapy.spider import BaseSpider | |
| from scrapy.selector import HtmlXPathSelector | |
| from scrapy.item import Item, Field | |
| from scrapy.contrib.loader import XPathItemLoader | |
| from scrapy.contrib.loader.processor import MapCompose, TakeFirst | |
| from scrapy.contrib.exporter import CsvItemExporter | |
| from scrapy.conf import settings |