I'm trying to WebScrap data from a currency website.
I don't really know how to get the specific span that I'm trying to get here.
If you execute my code basically you will get like 4 numbers, I need to get only the second one.
5 Replies
The
HtmlAgilityPack
uses XPath, which is in your commented code, that's the correct way. Find and isolate the correct HTML entity and retrieve the value you need.
Besides this, there are plenty of currency API's out there, no need to webscrape.And also... $scrape2
Before scraping:
1. Read this article: https://benbernardblog.com/web-scraping-and-crawling-are-perfectly-legal-right/
2. Use an API if one is provided, instead of scraping data.
3. Respect the Terms of Service (ToS).
4. Respect the rules of robots.txt.
Benoit Bernard
Web Scraping and Crawling Are Perfectly Legal, Right?
In this post, you'll find out more on the legal aspect of web scraping and crawling, and what possible consequences you might face.
Scraping is very often not allowed. Make sure you are not violating any terms and conditions before writing code
thanks for the advice!