Last active
November 23, 2019 14:35
-
-
Save Chestermozhao/4493a6ce2553e8008a44b56741445cbb to your computer and use it in GitHub Desktop.
scrapy_splash har log
This file contains 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 -*- | |
import logging | |
import sys | |
# create logger | |
logger_name = 'scrapy.splash.log' | |
log = logging.getLogger(logger_name) | |
log.setLevel(logging.DEBUG) | |
# set handler | |
handler = logging.StreamHandler(sys.stdout) | |
formatter = logging.Formatter('%(asctime)s:%(name)s:%(levelname)s:%(message)s') | |
handler.setFormatter(formatter) | |
log.addHandler(handler) |
This file contains 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 -*- | |
import json | |
from scrapy.spiders import Spider | |
from scrapy_splash import SplashRequest | |
from items import SplashTestItem | |
from logger import log | |
class SplashSpider(Spider): | |
name = "splash_har_log" | |
start_urls = ["https://www.livescore.bet3000.com/"] | |
def start_requests(self): | |
splash_args = { | |
'wait': 6, | |
'html': 1, | |
'har': 1 | |
} | |
for url in self.start_urls: | |
yield SplashRequest(url, self.parse, endpoint='render.json', args=splash_args) | |
def parse(self, response): | |
log.info(str(response.data["har"])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment