Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="houses">
- <input type="hidden" class="houseNumber" value="107">
- <input type="hidden" class="houseState" value="MT">
- <input type="hidden" class="houseStatus" value="Occupied">
- <div class="houseInfo">
- <div class="houseCity">Helena</div>
- <div class="houseArea">Helena Valley</div>
- </div>
- </div>
- <div class="houses">
- <input type="hidden" class="houseNumber" value="237">
- <input type="hidden" class="houseState" value="MT">
- <input type="hidden" class="houseStatus" value="Occupied">
- <div class="houseInfo">
- <div class="houseCity">East Helena</div>
- <div class="houseArea">Helena Valley</div>
- </div>
- </div>
- <div class="houses">
- <input type="hidden" class="houseNumber" value="104">
- <input type="hidden" class="houseState" value="MT">
- <input type="hidden" class="houseStatus" value="Vacant">
- <div class="houseInfo">
- <div class="houseCity">Helena</div>
- <div class="houseArea">Helena Valley</div>
- </div>
- </div>
- ['107', 'MT', 'Occupied', 'Helena', 'Helena Valley']
- ['237', 'MT', 'Occupied', 'East Helena', 'Helena Valley']
- ['104', 'MT', 'Vacant', 'Helena', 'Helena Valley']
- ['107', '237', '104']
- ['MT', 'MT', 'MT']
- ['Occupied', 'Occupied', 'Vacant']
- ['Helena', 'East Helena', 'Helena']
- ['Helena Valley', 'Helena Valley', 'Helena Valley']
- ['107', '237', '104']
- ['MT', 'MT', 'MT']
- ['Occupied', 'Occupied', 'Vacant']
- ['Helena', 'East Helena', 'Helena']
- ['Helena Valley', 'Helena Valley', 'Helena Valley']
- ['107', '237', '104']
- ['MT', 'MT', 'MT']
- ['Occupied', 'Occupied', 'Vacant']
- ['Helena', 'East Helena', 'Helena']
- ['Helena Valley', 'Helena Valley', 'Helena Valley']
- link = "example.com"
- headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
- response = requests.get(link, headers=headers, allow_redirects=False)
- sourceCode = response.content
- htmlElem = html.document_fromstring(sourceCode)
- houses = htmlElem.find_class('houses')
- for house in houses:
- houseNumber = house.xpath('//input[@class="houseNumber"]/@value')
- houseState = house.xpath('//input[@class="houseState"]/@value')
- houseStatus = house.xpath('//input[@class="houseStatus"]/@value')
Add Comment
Please, Sign In to add comment