Skip to content

Instantly share code, notes, and snippets.

@nguaman
Last active November 25, 2018 05:54
Show Gist options
  • Save nguaman/eb4e088fead7c23ce46d to your computer and use it in GitHub Desktop.
Save nguaman/eb4e088fead7c23ce46d to your computer and use it in GitHub Desktop.
from sys import exit
import lxml.html
import requests
url = 'http://www.myfxbook.com/community/outlook'
doc = requests.get(url)
root = lxml.html.fromstring(doc.text)
all_id_inputs = root.xpath("//input[starts-with(@id,'outlookTip')]/@id")
for ids in all_id_inputs:
xpath_value = '//*[@id="{}"]/@value'.format(ids)
table_value = root.xpath(xpath_value)
root_table = lxml.html.fromstring(table_value[0])
# print table_value[0]
# print
firt_value = root_table.xpath("//table/tr[2]/td[3]/text()")
second_value = root_table.xpath("//table/tr[3]/td[3]/text()")
third_value = root_table.xpath("//div/text()")[1]
print firt_value
print second_value
print third_value
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment