I am trying to make a python script to scrape specific information from a webpage with the limited knowledge I have. But I guess my limited knowledge is not suffice. I need to extract 7-8 pieces of information. The tags are as follows -
1
<a class="ui-magnifier-glass" href="here goes the link that i want to extract" data-spm-anchor-id="0.0.0.0" style="width: 258px; height: 258px; position: absolute; left: -1px; top: -1px; display: none;"></a>
2
<a href="link to extract" title="title to extract" rel="category tag" data-spm-anchor-id="0.0.0.0">or maybe this word instead of title</a>
If i get an idea how to extract information from such href tags. I will be able to do rest of the work myself.
And also if someone could help me in writing a code to add this information in a csv file would be highly appreciated.
I have started with this code
url = raw_input('url : ')
page = requests.get(url)
tree = html.fromstring(page.text)
productname = tree.xpath('//h1[@class="product-name"]/text()')
price = tree.xpath('//span[@id="sku-discount-price"]/text()')
print '\n' + productname[0]
print '\n' + price[0]