【问题标题】:getting 'browser is unsupported' when trying to srape page - Python尝试抓取页面时获取“不支持浏览器”-Python
【发布时间】:2023-03-18 07:20:01
【问题描述】:

您好,我想使用 requestsBeautifulSoup 抓取页面帖子,但收到消息 Sorry, your browser is unsupported. 我尝试使用不同的 User-Agent,但消息相同。
我的代码

import requests
from bs4 import BeautifulSoup
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'}
r = requests.get(
    'https://disqus.com/home/forum/bscscan/', headers=headers)
print(r.text)
# soup = BeautifulSoup(r.text,"html.parser")
# print(soup.title.string)

# x = soup.select("a")
# print(x)

【问题讨论】:

    标签: python beautifulsoup python-requests


    【解决方案1】:

    试试这个:

    import requests
    from bs4 import BeautifulSoup
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'}
    r = requests.get(
        'https://disqus.com/api/3.0/timelines/activities?type=profile&target=forum%3Abscscan&cursor=&limit=10&api_key=E8Uh5l5fHZ6gD8U3KycjAIAk46f68Zw7C6eW8WSjZvCLXebZ7p0r1yrYDrLilk2F', headers=headers)
    

    你应该得到带有数据的json

    【讨论】:

      猜你喜欢
      • 2021-06-24
      • 1970-01-01
      • 2013-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多