Guest User

Untitled

a guest
Feb 18th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. <div class="houses">
  2. <input type="hidden" class="houseNumber" value="107">
  3. <input type="hidden" class="houseState" value="MT">
  4. <input type="hidden" class="houseStatus" value="Occupied">
  5. <div class="houseInfo">
  6. <div class="houseCity">Helena</div>
  7. <div class="houseArea">Helena Valley</div>
  8. </div>
  9. </div>
  10. <div class="houses">
  11. <input type="hidden" class="houseNumber" value="237">
  12. <input type="hidden" class="houseState" value="MT">
  13. <input type="hidden" class="houseStatus" value="Occupied">
  14. <div class="houseInfo">
  15. <div class="houseCity">East Helena</div>
  16. <div class="houseArea">Helena Valley</div>
  17. </div>
  18. </div>
  19. <div class="houses">
  20. <input type="hidden" class="houseNumber" value="104">
  21. <input type="hidden" class="houseState" value="MT">
  22. <input type="hidden" class="houseStatus" value="Vacant">
  23. <div class="houseInfo">
  24. <div class="houseCity">Helena</div>
  25. <div class="houseArea">Helena Valley</div>
  26. </div>
  27. </div>
  28.  
  29. ['107', 'MT', 'Occupied', 'Helena', 'Helena Valley']
  30. ['237', 'MT', 'Occupied', 'East Helena', 'Helena Valley']
  31. ['104', 'MT', 'Vacant', 'Helena', 'Helena Valley']
  32.  
  33. ['107', '237', '104']
  34. ['MT', 'MT', 'MT']
  35. ['Occupied', 'Occupied', 'Vacant']
  36. ['Helena', 'East Helena', 'Helena']
  37. ['Helena Valley', 'Helena Valley', 'Helena Valley']
  38. ['107', '237', '104']
  39. ['MT', 'MT', 'MT']
  40. ['Occupied', 'Occupied', 'Vacant']
  41. ['Helena', 'East Helena', 'Helena']
  42. ['Helena Valley', 'Helena Valley', 'Helena Valley']
  43. ['107', '237', '104']
  44. ['MT', 'MT', 'MT']
  45. ['Occupied', 'Occupied', 'Vacant']
  46. ['Helena', 'East Helena', 'Helena']
  47. ['Helena Valley', 'Helena Valley', 'Helena Valley']
  48.  
  49. link = "example.com"
  50. 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'}
  51. response = requests.get(link, headers=headers, allow_redirects=False)
  52. sourceCode = response.content
  53.  
  54. htmlElem = html.document_fromstring(sourceCode)
  55. houses = htmlElem.find_class('houses')
  56. for house in houses:
  57. houseNumber = house.xpath('//input[@class="houseNumber"]/@value')
  58. houseState = house.xpath('//input[@class="houseState"]/@value')
  59. houseStatus = house.xpath('//input[@class="houseStatus"]/@value')
Add Comment
Please, Sign In to add comment