A
A
azukizxc2021-10-14 12:55:20
Python
azukizxc, 2021-10-14 12:55:20

Why can't I transfer text from a block to a text document?

I am writing a site parser with cs:go skins, you need to know the name of the skin, quality and price.
But, this data is not loaded into the text editor.

from selenium import webdriver

driver = webdriver.Chrome(executable_path="E:\\Users\\Azuki\\PycharmProjects\\pars\\chromedriver\\chromedriver.exe")

f = open("skinsinfo.txt", "w")
count = 0
i = 0
try:
    with open('skins.txt', 'r') as f:
        for line in f:
            driver.get(line)
            checkname = driver.find_element_by_class_name("skin-name")
            print(checkname.text)
            checkinfo = driver.find_element_by_class_name('info-item')
            print(checkinfo.text)
            checkprice = driver.find_element_by_class_name('min-price-value')
            print(checkprice.text)
            skinsinfo = str(checkname+("|")+checkinfo+("|")+checkprice) + "\n"
            f.write(skinsinfo)

except Exception as ex:
    print(ex)


Yes, there are no links in the code, I parsed all the skins as links into one file and I need them to get one by one and check for the requests I set.

error:
unsupported operand type(s) for +: 'WebElement' and 'str'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-10-14
@Vindicar

Inattention is the mother of insanity. =) You named both files as f.
f = open("skinsinfo.txt", "w")
count = 0
i = 0
try:
with open('skins.txt', 'r') as f :

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question