Scraper in Python gives “Access Denied”

前端 未结 3 1278
青春惊慌失措
青春惊慌失措 2020-12-19 12:35

I\'m trying to code a scraper in Python to get some info from a page. Like the title of the offers that appear on this page:
https://www.justdial.com/Panipat/Saree-Retai

3条回答
  •  佛祖请我去吃肉
    2020-12-19 12:59

    def extract_source(url):
        headers = {"User-Agent":"Mozilla/5.0"}
        source=requests.get(url, headers=headers).text
        return source
    

    out:

    Saree Retailers in Panipat - Best Deals online - Justdial
    

    Add User-Agent to your request, some site do not response to the request which dnose not has User-Agent

提交回复
热议问题