1
私はPythonでMechanizeを使用していくつかのWebスクレイピングを実行しています。ウェブサイトのほとんどは動作しますが、特定のページはコンテンツやレスポンスを返しません。機械化されたレスポンスは内容を返しません
私の設定は
self._browser = mechanize.Browser()
self._browser.set_handle_refresh(True)
self._browser.set_debug_responses(True)
self._browser.set_debug_redirects(True)
self._browser.set_debug_http(True)
および実行するためのコードは次のとおりです。
add_cookie_header
Checking xyz.com for cookies to return
- checking cookie path=/
- checking cookie <Cookie ASP.NET_SessionId=j3pg0wnavh3yjseyj1v3mr45 for xyz.com/>
it's a match
send: 'GET /page.aspx?leagueID=39 HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: xyz.com\r\nCookie: ASP.NET_SessionId=aapg9wnavh3yqyrtg1v3ar45\r\nConnection: close\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Date: Tue, 07 Feb 2012 19:04:37 GMT
header: Pragma: no-cache
header: Expires: -1
header: Connection: close
header: Cache-Control: no-cache
header: Content-Length: 0
extract_cookies: Date: Tue, 07 Feb 2012 19:04:37 GMT
Pragma: no-cache
Expires: -1
Connection: close
Cache-Control: no-cache
Content-Length: 0
は私がにリダイレクトしてとせずに試してみた:これは、デバッグ出力である
response = self._browser.open(url)
役立たず。何か案は?
ページをブラウザに正常に追加できる場合があります。
fiddlerやcharlesなどのデバッグプロキシは、wiresharkよりもはるかに優れています。 – pguardiario
@pguardiarioご意見ありがとうございます。私はそれらのどれも使用したことはありませんが、たとえオープンソースでなくても役に立つと思われます。 – jcollado
Chromeでデベロッパーセッションを開始したところ、問題を解決するのに役立つようでした。ありがとう –