抓取数据时找不到标签

发布于 2025-01-10 16:48:21 字数 970 浏览 0 评论 0原文

我是 Python 新手,一直在开发一个程序,该程序会在新商品上传到 jp.mercari.com(购物网站)时提醒您。我的程序的警报部分正在运行,但它是根据搜索结果中出现的项目数量来运行的。当我抓取网站时,尽管在检查页面上的元素时能够找到我要查找的内容,但我无法找到它。抓取程序如下所示:

from bs4 import BeautifulSoup
import requests

url = "https://jp.mercari.com/search?keyword=pachinko"

result = requests.get(url)
doc = BeautifulSoup(result.text, "html.parser")

tag = doc.find_all("mer-text")
print(tag)

对于更多上下文,这是网站和一些 HTML。我用红色圈出了我想要找到的部分: 网站和 html 的屏幕截图

有谁知道为什么我找不到我要找的内容?

这是同一问题的另一个示例,但来自英文网站:

import requests


url = "https://www.vinted.co.uk/vetements?search_text=pachinko"

result = requests.get(url)
doc = BeautifulSoup(result.text, "html.parser")

tag = doc.find_all("span")
print(tag)

同样,当我检查元素时,我可以看到我想要找到的 HTML 部分,但当我抓取网站时却找不到它: 网站截图和html

I am new to Python and I've been working on a program that alerts you when a new item is uploaded to jp.mercari.com (a shopping site). I have the alert part of the program working, but it operates based on the number of items that come up on the search results. When I scrape the website I am unable to find what I am looking for despite being able to locate it when I inspect element on the page. The scraping program looks like this:

from bs4 import BeautifulSoup
import requests

url = "https://jp.mercari.com/search?keyword=pachinko"

result = requests.get(url)
doc = BeautifulSoup(result.text, "html.parser")

tag = doc.find_all("mer-text")
print(tag)

For more context, this is the website and some of the HTML. I've circled the parts I am trying to find in red:
screenshot of website and html

Does anyone know why I am unable to find what I'm looking for?

Here is another example of the same problem but from a website that is in English:

import requests


url = "https://www.vinted.co.uk/vetements?search_text=pachinko"

result = requests.get(url)
doc = BeautifulSoup(result.text, "html.parser")

tag = doc.find_all("span")
print(tag)

Again, I can see the part of HTML I want to find when I inspect element but I can't find it when I scrape the website: screenshot of website and html

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾城月光淡如水﹏ 2025-01-17 16:48:21

这就是我遇到的情况:正在找到您要查找的元素 ()。然而,输出是日语的,Python 不知道如何处理它。在我的浏览器中,谷歌会自动将其翻译成英文,因此更容易处理。

Here's what's happening with me: the element you seek (<mer-text>) is being found. However, the output is in Japanese, and Python doesn't know what to do with that. In my browser, it's being translated to English automatically by Google, so that's easier to deal with.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文