python requests & beautifulsoup bot detection

前端 未结 3 1222
一整个雨季
一整个雨季 2021-01-22 15:25

I\'m trying to scrape all the HTML elements of a page using requests & beautifulsoup. I\'m using ASIN (Amazon Standard Identification Number) to get the product details of a

3条回答
  •  孤街浪徒
    2021-01-22 15:36

    try this:

    import requests
    from bs4 import BeautifulSoup
    
    url = "http://www.amazon.com/dp/" + 'B004CNH98C'
    r = requests.get(url)
    r = r.text
    
    ##options #1
    #  print r.text
    
    soup = BeautifulSoup( r.encode("utf-8") , "html.parser")
    
    ### options 2
    print(soup)
    

提交回复
热议问题