【问题标题】:beautiful soup url with # in it漂亮的汤网址,里面有#
【发布时间】:2020-05-10 09:38:55
【问题描述】:

我正在尝试抓取 URL 中带有 ?, =, # 的网站。当我这样做时,我会被重定向。我想我已经将问题字符缩小到#。我认为它正在尝试对# 进行百分比编码。在我的情况下,它不是一个锚,它在许多页面上排序项目 编辑:我认为是 requests 导致了错误,并且 # 通常是客户端专用参数,不会发送到服务器

工作网址

www.foo.com/

www.foo.com/example

www.foo.com/example/search?q=&%5B%5D

错误的 URL(即使在浏览器中也会拉出相同的无错误页面)

www.foo.com/example/#page1

www.foo.com/example/%23page1(百分比编码#)

www.foo.com/example/something_that_does_not_exsit

response = requests.get(r"www.foo.com/example/#page1")
response.url
soup = BeautifulSoup(response.text, 'html.parser')

【问题讨论】:

    标签: python-3.x url beautifulsoup


    【解决方案1】:

    你检查过这个吗?可能有用,看看 Selenium。

    Beautifulsoup and link with a hash #

    【讨论】:

    • 我不想使用 Selenium,也许我遗漏了一些东西,但它会导致其他问题
    • 我正在尽我所能,遇到 Selenium 问题
    猜你喜欢
    • 1970-01-01
    • 2017-09-09
    • 2017-04-18
    • 1970-01-01
    • 2012-10-18
    • 2017-08-15
    • 2014-04-22
    • 2012-03-07
    • 1970-01-01
    相关资源
    最近更新 更多