xpath

How to extract the text from the search results of duckduckgo using Selenium Python

五迷三道 提交于 2021-02-15 05:18:16
问题 I am trying to get the link descriptions of duckduck of search results using the following: results=browser.find_elements_by_xpath("//div[@id='links']/div/div/div[2]") description=[] for result in results: description.append(result.text) I am getting the error 'list' object has no attribute 'text'. I was able to use a similar method to get the search result titles, but for some reason I am unable to extract the text from this particular xpath. 回答1: To extract the link descriptions of the

How to extract the text from the search results of duckduckgo using Selenium Python

随声附和 提交于 2021-02-15 05:17:36
问题 I am trying to get the link descriptions of duckduck of search results using the following: results=browser.find_elements_by_xpath("//div[@id='links']/div/div/div[2]") description=[] for result in results: description.append(result.text) I am getting the error 'list' object has no attribute 'text'. I was able to use a similar method to get the search result titles, but for some reason I am unable to extract the text from this particular xpath. 回答1: To extract the link descriptions of the

How to use XPath contains()

空扰寡人 提交于 2021-02-11 17:44:48
问题 My XML <r> <ul> <li>ModelA</li> <bi>Foo</bi> </ul> <ul> <li>ModelB</li> <bi>boo</bi> </ul> </r> For specific node value I want to extract the value of the successor node. Example when li = ModelA get the value of bi which is Foo My Xpath : //ul[li[contains(.,'ModelA')]] 回答1: Your XPath does not contain bi , so it will not select a bi -Node. Start with //ul/bi which selects the bi -node. Now add the conditions in square brackets. The first condition is "the parent node has a li -subnode: //ul

xpath to obtain texts between 2 tags in IMPORTXML formula

狂风中的少年 提交于 2021-02-11 17:01:36
问题 EDIT- I have changed xpaths. odds xpath and result xpath are exactly what I want. But the Race url and race num do not correspond to this data. I have found an xpath that returns the info that I need but it returns all data and I only need data between Australia and new zealand. I have 3 xpaths that I need refined. Sample URL: https://www.punters.com.au/form-guide/2020-02-06/ Race URL XPATH - //*[@class='component-wrapper form-guide-index']/table1/tbody/tr//td/a/@href Race Result XPATH - /

parse xpath from xml file should contain '

烂漫一生 提交于 2021-02-11 15:55:49
问题 this is my xml file <Item name="Date" xpath='p[@class="date"]/text()' defaultValue="Date Not Found"></Item> i parse it like this: self.doc=etree.parse(xmlFile) masterItemsFromXML = self.doc.findall('MasterPage/MasterItems/Item') for oneItem in masterItemsFromXML: print 'master item xpath = {0}'.format(oneItem.attrib['xpath']) and I can see the result printed in the cmd like this: master item xpath =p[@class="date"]/text() my problem the xpath is not valid because it should start with ' and

parse xpath from xml file should contain '

痞子三分冷 提交于 2021-02-11 15:55:21
问题 this is my xml file <Item name="Date" xpath='p[@class="date"]/text()' defaultValue="Date Not Found"></Item> i parse it like this: self.doc=etree.parse(xmlFile) masterItemsFromXML = self.doc.findall('MasterPage/MasterItems/Item') for oneItem in masterItemsFromXML: print 'master item xpath = {0}'.format(oneItem.attrib['xpath']) and I can see the result printed in the cmd like this: master item xpath =p[@class="date"]/text() my problem the xpath is not valid because it should start with ' and

C# What query language to specify in rule to pull out the two book nodes

女生的网名这么多〃 提交于 2021-02-11 15:12:30
问题 <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <book category="WEB"> <title lang="en">XQuery Kick Start</title> <author>James McGovern</author> <author>Per Bothner</author> <author>Kurt Cagle<

C# What query language to specify in rule to pull out the two book nodes

最后都变了- 提交于 2021-02-11 15:12:19
问题 <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <book category="WEB"> <title lang="en">XQuery Kick Start</title> <author>James McGovern</author> <author>Per Bothner</author> <author>Kurt Cagle<

Webscraping: ElementNotInteractableException while trying to fill the form on this website

天大地大妈咪最大 提交于 2021-02-11 14:50:45
问题 I have been trying to scrape data from this site. I need to fill Get the precise price of your car form ie. the year, make, model etc.. I have written the following code till now: import requests import time from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait, Select from selenium.common.exceptions import NoSuchElementException from selenium.common

XSLT select the second occurrence of an attribute

瘦欲@ 提交于 2021-02-11 14:34:18
问题 Is there a dynamic way to get the 2nd occurrence of an attribute ? For this XML example, I'd like to get the first 12 values of the SummaryCell/@Name value into a variable Month01, Month02, and so on; <SummaryHeader> <SummaryColumnGroup Name="2014"> <SummaryCell Name="Feb14" Type="Text" Value="Feb"/> <SummaryCell Name="Jan14" Type="Text" Value="Jan"/> </SummaryColumnGroup> <SummaryColumnGroup Name="2013"> <SummaryCell Name="Dec13" Type="Text" Value="Dec"/> <SummaryCell Name="Nov13" Type="Text