使用Python在iframe中引用mytubeid

2024-06-02 06:22:29 发布

您现在位置:Python中文网/ 问答频道 /正文

mytubeid标记(如<iframe src="/portal/corporateEventsCalendarIframe.html" mytubeid="mytube1" width="820" height="1600" frameborder="0"/>)在iframe中做什么?你知道吗

请注意,iframe中没有id或类似的名称!你知道吗

如何在代码中引用它?我正在使用python+selenium+scrapy来构建一个webscraping工具。你知道吗


Tags: 代码标记src名称idhtmlseleniumwidth
2条回答

看看这个:

http://selenium-python.readthedocs.io/locating-elements.html#locating-by-xpath

可以通过XPath定位元素。你知道吗

从网站:

One of the main reasons for using XPath is when you don’t have a suitable id or name attribute for the element you wish to locate.

如果您想使用selenium找到这个iframe,请尝试以下操作

driver.find_element_by_xpath('//iframe[@mytubeid="mytube1"]')。你知道吗

更明确的答案请提供一些代码和网站网址。你知道吗

相关问题 更多 >