Answer the question
In order to leave comments, you need to log in
How to get data from the internet?
Hello !
I wrote a program that shows simple moving averages, but I can't get data from the internet.
I need to download the date and price of oil from the Internet. How can I do this please tell me!
Thanks in advance !
Answer the question
In order to leave comments, you need to log in
#requests - для скачки странички
import requests
#html из lxml - чтобы парсить DOM дерево
from lxml import html
#забираем страничку с нефтью
raw = requests.get("https://yandex.ru/news/quotes/1006.html")
#строим из нее html дерево
dom = html.fromstring(raw.content)
#забираем xpath-ом ноды с датами и ценами из дерева
dates = dom.xpath('//td[@class="quote__date"]')
prices = dom.xpath('//td[@class="quote__value"]')
#выводим на экран
for d,p in zip(dates, prices):
print(d.text_content(), p.text_content())
selenium.
English tutorials:
https://www.youtube.com/watch?v=7ovFudqFB0Q
Here are the docs:
https://selenium-python.readthedocs.io/
Changed (Important):Although there is a simpler thing:
Beautiful Soup
Here Goshak made a parser for dollar rate:
https://www.youtube.com/watch?v=4L57oY3J378
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question