Forked from subvillion/Python: lxml xpath urllib2 .py
Created
January 16, 2019 06:21
-
-
Save 3rdman/771e04a64dc51d12c2fd859f4e04a30d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
import urllib2, lxml.html | |
... | |
file = urllib2.urlopen('http://m.rp5.ru/7259/ru') | |
data = file.read() | |
file.close() | |
doc = lxml.html.document_fromstring(data) | |
txt2 = doc.xpath('//*[@class="pr_0"]/text()') | |
osadki = txt2[0].strip(" \t\n") | |
txt2 = doc.xpath('//*[@class="finfo"]/text()') | |
oblach = txt2[4] | |
txt1 = doc.xpath(".//*[@id='archiveDiv']/text()[10]") | |
vl_wind = txt1[0].strip(" \t\n").replace(' ', ' ') | |
txt1 = doc.xpath('//*[@class="wv_1"]/text()') | |
wins_spd = txt1[0].strip(" \t\n") | |
print "%s, %s, %s %s" % (osadki, oblach, vl_wind, wins_spd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment