M
M
Mag1str2021-06-26 12:37:33
Python
Mag1str, 2021-06-26 12:37:33

How to make two parsers?

You need to send this data every day at 8 o'clock.
60d6f540bba3c755525263.png
Here's what I wrote, if 1 parser then works, and if 2 then it doesn't.

from selenium import webdriver
from time import sleep

option = webdriver.ChromeOptions()
option.add_argument('headless')

def toFixed(numObj, digits=0):
    return f"{numObj:.{digits}f}"

driver_price = webdriver.Chrome(chrome_options = option)
driver_price.get('https://www.google.com/search?q=%D0%BA%D0%B0%D0%BA+%D0%BD%D0%B0+python+%D0%BF%D0%BE%D1%81%D0%BB%D0%B5+%D0%B7%D0%B0%D0%BF%D1%8F%D1%82%D0%BE%D0%B9+%D0%B2%D1%8B%D0%B2%D0%B5%D1%81%D1%82%D0%B8+2+%D0%B7%D0%BD%D0%B0%D0%BA%D0%B0&oq=%D0%BA%D0%B0%D0%BA+%D0%BD%D0%B0+%D0%BF%D0%B8%D1%82%D0%BE%D0%BD%D0%B5+%D0%BF%D0%BE%D1%81%D0%BB%D0%B5+%D0%B7%D0%B0%D0%BF%D1%8F%D1%82%D0%BE%D0%B9+%D0%B2%D1%8B%D0%B2%D0%BE%D0%B4%D0%B8%D1%82%D1%8C&aqs=chrome.1.69i57j33i22i29i30l2.9048j0j7&sourceid=chrome&ie=UTF-8')
sleep(1)
price_usd_b = driver_price.find_element_by_xpath('//*[@id="rso"]/div[1]/div/div[1]/div/div[1]/div/div[1]/div/div[2]/table/tbody/tr[2]/td[2]')



# погода
driver = webdriver.Chrome(chrome_options = option)
driver.get('https://www.google.com/search?q=%D0%BF%D0%BE%D0%B3%D0%BE%D0%B4%D0%B0+%D0%BE%D0%B4%D0%B5%D1%81%D1%81%D0%B0&oq=%D0%BF%D0%BE%D0%B3%D0%BE%D0%B4%D0%B0+%D0%BE%D0%B4%D0%B5%D1%81%D1%81%D0%B0&aqs=chrome..69i57j0i457j0j0i20i263j0j69i60l3.2952j1j4&sourceid=chrome&ie=UTF-8')
sleep(1)
weather = driver.find_element_by_xpath('//*[@id="wob_tm"]')
weather_detail = driver.find_element_by_xpath('//*[@id="wob_dc"]')
print(" Погода в Одессе: " + weather_detail.text + " " + weather.text + " °С")


print("Доброе утро, друзья!\n\n")
print("Курс валют:\n")
print("Доллар\n")
print("Покупка: " + toFixed(price_usd_b) + " грн")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-06-26
@Vindicar

Is it possible to reuse the same driver?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question