最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】pyppeteer中如何定位查找百度搜索输入框

搜索 crifan 2066浏览 0评论
折腾:
【未解决】Mac中用puppeteer自动操作浏览器实现百度搜索
期间,继续:
类似的,先去Chromium中,查看输入框的html元素
<input id="kw" name="wd" class="s_ipt" value="" maxlength="255" autocomplete="off">
和之前是类似的。
后续就不介绍这些细节了,详见:
【已解决】Mac中用Selenium自动操作浏览器实现百度搜索
输入框 搜索框
看到关于定位元素:
Pyppeteer’s documentation — Pyppeteer 0.0.25 documentation
pyppeteer/pyppeteer: Headless chrome/chromium automation library (unofficial port of puppeteer)
  • pyppeteer
    • Page.querySelector()
      • Page.J()
    • Page.querySelectorAll()
      • Page.JJ()
    • Page.xpath()
      • Page.Jx()
去写xpath定位元素看看
puppeteer find by xpath
puppeteer – How can I get an element by xpath? – Stack Overflow
javascript – How to use xpath in chrome headless+puppeteer evaluate()? – Stack Overflow
node.js – How to click element in Puppeteer using xPath – Stack Overflow
javascript – Get all links with XPath in Puppeteer (pausing or not working)? – Stack Overflow
javascript – Proper way to get XPath lists in Chrome Puppeteer – Stack Overflow
pyppeteer find by xpath
python 3.x – How to get element attribute by xpath in pyppeteer – Stack Overflow
javascript – select a button by its text in Pyppeteer (Python Puppeteer) – Stack Overflow
pyppeteer- How to goto next page by clicking sub link (href) in a page using python pyppeteer – Stack Overflow
javascript – Getting element content with pyppeteer – Stack Overflow
puppeteer – Python: Pyppeteer clicking on pop up window – Stack Overflow
    SearchButtonXpath = "//input[@id='kw']"
    searchButtonElem = page.xpath(SearchButtonXpath)
    print("searchButtonElem=%s" % searchButtonElem)
结果:
searchButtonElem=<coroutine object Page.xpath at 0x10f15cdb0>
不知道是否真的找到值了。
那就继续试试:
【已解决】pyppeteer如何给输入框中输入文字
【总结】
此处无需定位元素,直接用selector定位并type输入即可。
详见:
【已解决】pyppeteer如何给输入框中输入文字

转载请注明:在路上 » 【已解决】pyppeteer中如何定位查找百度搜索输入框

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
80 queries in 0.171 seconds, using 22.10MB memory