Last active
November 25, 2018 05:54
-
-
Save nguaman/eb4e088fead7c23ce46d to your computer and use it in GitHub Desktop.
Parsing #1 [www.myfxbook.com/community/outlook]
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
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] | |
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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment