I'm searching the xpath query to scrape the "algo score" from this webpage. The algo score is highlighted with a red border in this screenshot.
I've tried several Xpath queries without results such as:
//*[#id="content"]/main/section/div/div/header/div[7]/span[2]/a/text()
//a[#class="no-und label label-ghost text-sm"]//text()
//div[#ng-if="::details.total_score"]/a/text()
You could try:
string(.//a[#href = '/coins/cardano/analysis'])
Related
I am trying to get only order numbers like "190795". check the image
What i have tried
self.driver.find_element_by_xpath('//div[#class="sc-kafWEX ihwrOP"]//div/div/div[3]').text
But it will return span text such as "Order number:190795" like this.
I want only "190795"
This is my HTMl code
That is a text node, you can not write an XPath (v1.0) for that, and Selenium make use of XPath v1.0 , so you will have to be dependent on binding language.
Try this:
org_text = self.driver.find_element_by_xpath('//div[#class="sc-kafWEX ihwrOP"]//div/div/div[3]').text
desired_text = org_text.split(':')[1]
print(desired_text)
I'm trying to scrape this webpage:
https://www.nextory.se/bok/heroine-mons-kallentoft-markus-lutteman/9789188345844
I want to scrapte the title, the cover photo, the book description, and the book info in the bottom.
I tried for 2 hours figuring out the correct Xpath formula for Google Sheets...
There is for example the division "single__Book__textcontent" that should give me the text from this div, but cannot get it to work in sheets!
Tried this one without success:
=IMPORTXML(A1,"//div[#class='div.single__Book__textcontent']")
I am trying to scrape full reviews from this webpage. (Full reviews - after clicking the 'Read More' button). This I am doing using RSelenium. I am able to select and extract text from the first <p> element, using the code
reviewNodes <- mybrowser$findElements(using = 'xpath', "//p[#id][1]")
which is for less text review.
But not able to extract full text reviews using the code
reviewNodes <- mybrowser$findElements(using = 'xpath', "//p[#id][2]")
or
reviewNodes <- mybrowser$findElements(using = 'xpath', "//p[#itemprop = 'reviewBody']")
It shows blank list elements. I don't know what is wrong. Please help me..
Drop the double slash and try to use the explicit descendant axis:
/descendant::p[#id][2]
(see the note from W3C document on XPath I mentioned in this answer)
As you're dealing with a list, you should first find the list items, e.g. using CSS selector
div.srm
Based on these elements, you can then search on inside the list items, e.g. using CSS selector
p[itemprop='reviewBody']
Of course you can also do it in 1 single expression, but that is not quite as neat imho:
div.srm p[itemprop='reviewBody']
Or in XPath (which I wouldn't recommend):
//div[#class='srm']//p[#itemprop='reviewBody']
If neither of these work for you, then the problem must be somewhere else.
I'm using Chrome Data Miner, and so far, failing to extract the data from my query: http://www.allinlondon.co.uk/restaurants.php?type=name&rest=gluten+free
How to code the Next Element Xpath for this website? I tried all the possible web sources, nothing worked.
Thanks in advance!
You could look for a tags (//a) whose descendant::text() starts with "Next" and then get the href attribute of that a element.
% xpquery -p HTML '//a[starts-with(descendant::text(), "Next")]/#href' 'http://www.allinlondon.co.uk/restaurants.php?type=name&rest=gluten+free'
href="http://www.allinlondon.co.uk/restaurants.php?type=name&tube=0&rest=glutenfree®ion=0&cuisine=0&start=30&ordering=&expand="
I am working on project with java and selenium webdriver 2.44, we need the closest element of text. For example I have email text on page and i need the closest element that is text box. I have run the below given xpath query on facebook.com. However, it finds numbers of input type that is email and text. We do not need jQuery to run as we are using selenium webdriver.
.//*[contains(text(),'Email')]/following::input[#type='email' or #type='text']
Can anyone provide me xpath query to find closest element on page. Or a tutorial site where I can learn how to query.
Not a perfect solution, though in facebook scenario u can find first element as:
(.//*[contains(text(),'Email')]/following::input[#type='email' or #type='text'])[1]
Another thing to add if you are getting multiple elements for your query you can use:
List<WebElement> txtList = new ArrayList<WebElement>();
txtList = driver.findElements(By.xpath(".//*[contains(text(),'Email')]/following::input[#type='email' or #type='text']"));
and use txtList.get(0).sendKeys("abcd");