How to provide xpath value for web scraping

0 votes
How to create XPath value from HTML elements? I used CSS so far for web scraping but I want to learn how to create XPath value. Can someone explain?
Sep 17, 2019 in Data Analytics by karthick
986 views

1 answer to this question.

0 votes

Hey Karthik,

XPath uses path expressions to select nodes in an XML/HTML document. The node is selected by following a path or steps. 

The useful path expressions are listed below:

Expression Description
nodename Selects all nodes with the name "nodename"
/ Selects from the root node
// Selects nodes in the document from the current node that matches the selection no matter where they are
. Selects the current node
.. Selects the parent of the current node
@ Selects attributes

 Example - 

/div/span/#id_name/.class_name

You can find examples and explanation here,

answered Sep 18, 2019 by anonymous
• 33,030 points

Related Questions In Data Analytics

0 votes
2 answers

How to use group by for multiple columns in dplyr, using string vector input in R?

data = data.frame(   zzz11def = sample(LETTERS[1:3], 100, replace=TRUE),   zbc123qws1 ...READ MORE

answered Aug 6, 2019 in Data Analytics by anonymous
14,090 views
0 votes
1 answer

How to find out the sum/mean for multiple variables per group in R?

You can use the reshape2 package for ...READ MORE

answered Apr 12, 2018 in Data Analytics by DataKing99
• 8,250 points
3,825 views
0 votes
1 answer

How to wait for a keypress in R?

It is easy by using readline readline(prompt="Press any ...READ MORE

answered Apr 25, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,761 views
0 votes
1 answer

How to delete DataFrame row in pandas based upon a column value?

You can use drop function in your ...READ MORE

answered May 3, 2018 in Data Analytics by DeepCoder786
• 1,720 points

edited Jun 9, 2020 by MD 1,621 views
0 votes
1 answer

Error saying "Error in x$children[[1]] : subscript out of bounds" while web scrapping

You could try the httr library: library(XML) library(httr) url <- 'http://www.sainsburys.co.uk/shop/gb/groceries/fruit-veg/all-fruit#langId=44&storeId=10151&catalogId=10122&categoryId=12545&parent_category_rn=12518&top_category=12518&pageSize=30&orderBy=FAVOURITES_FIRST&searchTerm' doc <- ...READ MORE

answered Nov 9, 2018 in Data Analytics by Maverick
• 10,840 points
2,209 views
0 votes
1 answer
0 votes
1 answer

How to provide color to ggplot scatter chart depending on field value?

cyl is a continuous value field, so ...READ MORE

answered Nov 2, 2019 in Data Analytics by anonymous
• 33,030 points
822 views
0 votes
1 answer

How to provide names for list elments in r?

There are 2 ways to add names ...READ MORE

answered Oct 14, 2019 in Data Analytics by Cherukuri
• 33,030 points
697 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP