Why can't I scrape Amazon by BeautifulSoup?

前端 未结 4 2034
谎友^
谎友^ 2021-01-17 04:10

Here is my python code:

import urllib2
from bs4 import BeautifulSoup

page = urllib2.urlopen("http://www.amazon.com/")
soup = BeautifulSoup(page)
pr         


        
4条回答
  •  轮回少年
    2021-01-17 04:32

    I just ran into this and found that setting any user-agent will work. You don't need to lie about your user agent.

    response = HTTParty.get @url, headers: {'User-Agent' => 'Httparty'}
    

提交回复
热议问题