0

I'm trying to grab the following data but I'm unsure how.

So, first thing I'm trying to grab is this

<div style="background-color: #eee; margin: 0px; padding-left: 15px; font-size: 12px; padding-top: 5px; border-right: 5px solid crimson !important;">
Field-Tested / Covert Rifle

I want to grab the "Field-Tested / Covert Rifle".

I did the following but got a null exception.

var wear = WebUtility.HtmlDecode(node.SelectSingleNode(@".//div[@style=""background-color: #eee; margin: 0px; padding-left: 15px; font-size: 12px; padding-top: 5px; border-right: 5px solid crimson !important;""]").InnerText);

Also the second bit of data I want to grab is

<div class="item-icon" style="background-image: url(https://steamcommunity-a.akamaihd.net/economy/image/-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXH5ApeO4YmlhxYQknCRvCo04DEVlxkKgpot7HxfDhjxszJemkV086jloKOhcj5Nr_Yg2YfvZcg0rmXrI2n31ex8ks9Zjz2JIKdcVA4ZArRqVm-wLzn1sC8uJnMwWwj5HcoJjKuZA/256fx256f);">

I have no idea how to even attempt this, lastly is this bit of data and I have no idea as well.

<a href='/price/?market_hash_name=AK-47%20%7C%20Vulcan%20(Field-Tested)' target=_blank style='color: black;'>$23.68</a></small></p>

The reason I don't know how to do this part is because the href will be different each time. So I'm unsure how to do this...

John Craft
  • 53
  • 3
  • your `SelectSingleNode` is failing because with XPath you need to 'escape' special characters which is half of that style attribute ([e.g. see this](http://stackoverflow.com/questions/1341847/special-character-in-xpath-query)). Also that's a bad way to handle it, go after 'smaller bits' matching and e.g. use `contains` etc. I didn't even get into other details here as you have to do some homework here first (SO isn't meant to solve everything just specific questions - this is too general normally) – NSGaga-mostly-inactive Jun 09 '16 at 23:13
  • I can't find anything on google to help though... This is the problem. – John Craft Jun 10 '16 at 18:08
  • XPath is your friend - that's cross platform standard and internet full of links for it (Java, C# whatever, all is similar mostly, depends on the standard 1. or 2.0 I think but close) - that'll solve most of your issues + HtmlAgilityPack examples (check their source) - I know it's not too detailed but it has enough inside – NSGaga-mostly-inactive Jun 10 '16 at 18:49
  • Share the http address you are trying to scrape. – Veverke Jun 13 '16 at 10:29

0 Answers0