Good day. I just can not understand why the error flies:
File "D: /Python/Parser/pars.py", line 41, in startGrab cursor.execute (query, tmatch) TypeError: not converted
Here is the code:
from bs4 import BeautifulSoup import requests import psycopg2 conStr = "postgresql://parse:parse@localhost:5432/pars" conn = psycopg2.connect(conStr) cursor = conn.cursor() def startGrab(): base_url = 'http://localhost/way' url = base_url try: page = requests.get(url) except: print(url) soup = BeautifulSoup(page.content, "html5lib") for row in soup.find_all("tr", {"class" : "belowHeader"}): i = 0 x = 0 for row2 in row.find_all("td", {"class" : "tdteamname2"}): if i==0: team1 = row2.get_text() else: team2 = row2.get_text() i += 1 for row3 in row.find_all("td", {"class" : "tdpercentmw1"}): if x == 0: coef1 = row3.get_text() elif x == 1: coef2 = row3.get_text() else: coef3 = row3.get_text() x += 1 tmatch = team1+" "+team2+" "+coef1+" "+coef2+" "+coef3 print(tmatch) query = "INSERT INTO matches(text) VALUES (%s);" cursor.execute(query, tmatch) conn.commit() if __name__ == '__main__': startGrab()