0
스크립트가있는 페이지를 크롤링하기 위해 Scrapy (scrapyjs)를 적용하여 전체로드 된 페이지를 가져 오려고합니다. splash + scrapy를 적용하여 다음 코드로 렌더링했습니다. 로컬 호스트를 사용하는 것과 정확히 같은 인수입니다 : 8050 서버에 직접ScrapyJs (scrapy + splash)는 스크립트를로드 할 수 없지만 스플래시 서버는 정상적으로 작동합니다.
script = """
function main(splash)
local url = splash.args.url
assert(splash:go(url))
assert(splash:wait(0.5))
return {
html = splash:html(),
png = splash:png(),
har = splash:har(),
}
end
"""
splash_args = {
'wait': 0.5,
'url': response.url,
'images': 1,
'expand': 1,
'timeout': 60.0,
'lua_source': script
}
yield SplashRequest(response.url,
self.parse_list_other_page,
cookies=response.request.cookies,
args=splash_args)
응답 HTML은 내가 필요로하는 요소를 포함하지 않는,하지만 난 로컬 호스트에 직접 사용하는 경우 시작 서버가 잘 작동 : 8050.
문제의 위치를 알고 계십니까?
This is my settings.py
SPLASH_URL = 'http://127.0.0.1:8050'
SPIDER_MIDDLEWARES = {
'scrapy_splash.SplashDeduplicateArgsMiddleware': 100,
}
# Enable or disable downloader middlewares
# See http://scrapy.readthedocs.org/en/latest/topics/downloader-middleware.html
DOWNLOADER_MIDDLEWARES = {
'scrapy_splash.SplashCookiesMiddleware': 723,
'scrapy_splash.SplashMiddleware': 725,
# scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 750,
'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware': 810,
}
# Crawl responsibly by identifying yourself (and your website) on the
user-agent
USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111
Safari/537.36"
SPIDER_MIDDLEWARES = {
'scrapy_splash.SplashDeduplicateArgsMiddleware': 100,
}
# Enable or disable downloader middlewares
# See http://scrapy.readthedocs.org/en/latest/topics/downloader-middleware.html
DOWNLOADER_MIDDLEWARES = {
'scrapy_splash.SplashCookiesMiddleware': 723,
'scrapy_splash.SplashMiddleware': 725,
# scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 750,
'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware': 810,
}
2 초와 같이 '대기'값을 더 많이 설정하는 것에 지쳤습니까? – mizhgun
크롤링하려는 URL을 제공 할 수 있습니까? –