I’m trying do scrape this website with python and lxml.
Its working greate on my local machine, but when i try to deploy it on my server and run the script i got problems with whitespaces.
URL: http://www.samsungapps.com/topApps/topAppsDetail.as?productId=G00000467050&listYN=Y
Problem part in html:
<tr>
<th>Version</th>
<td>
1.0.0 (14.02.2011)
</td>
</tr>
I think it’s a problem of configuration of my server.
Does anyone got an idea what i missed?
Thanks in advance
Edit:
html = seite.read()
seite.close()
tree = etree.parse(StringIO.StringIO(html), parser)
xpath = "//div[contains(@class,'detail-view')]/h4/text()"
name = tree.xpath(xpath)
xpath = "//div[contains(@class,'detail-view')]/table/tbody/tr[2]/td/text()"
cat = tree.xpath(xpath)
xpath = "//div[contains(@class,'detail-view')]/table/tbody/tr[3]/td/text()"
typ = tree.xpath(xpath)
xpath = "//div[contains(@class,'detail-view')]/table/tbody/tr[4]/td/text()"
version = tree.xpath(xpath)
print name[0].encode("utf-8")
print cat[0].encode("utf-8")
print typ[0].encode("utf-8")
print version[0].encode("utf-8")
Adding
.strip()works for meTests