matthewmueller / x-ray

The next web scraper. See through the <html> noise.
MIT License
5.87k stars 349 forks source link

How to get a specific SPAN ID #330

Closed benSmith1981 closed 5 years ago

benSmith1981 commented 5 years ago

This is the extract from the webpage:

<h4 class="username">
<span id="ctl00_ctl00_ctl00_cphMain_cphMiddle_cphLeftColumn_widgetDiveSiteProfile_lblSiteName">
Tiger Beach
</span>
</h4>

I want to extract "Tiger Beach". What is syntax I used to get this?

span[id] But how can I get the text for this specific Span ID so not jsut all of them? I want to avoid doing a string search through all the Span IDs returned, and I just want this one for this ID?

"ctl00_ctl00_ctl00_cphMain_cphMiddle_cphLeftColumn_widgetDiveSiteProfile_lblSiteName" I can't find anywhere in the documentation or an example how to solve this (relatively simple) problem Thanks

benSmith1981 commented 5 years ago

Solution: You want the contents so between > < of a span id of "star5" do this span[id="star5"]