def get_stock(item_url):
source_code = requests.get(item_url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text, features="html.parser")
for link in soup.findAll('a',{'class':'none'}):
words=link.string
stock_num=words[1:5]
if stock_num.isdigit():
href='https://tw.stock.yahoo.com/q/q?s='+ stock_num
print(stock_num)
c.execute('insert into stocks(stocknum) values (?)',stock_num)
conn.commit()
I'm trying to insert four-digit strings stock_num
into my SQLite.
However, it shows
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 4 supplied.
Below is my code in creating table
CREATE TABLE "stocks" (
"stocknum" TEXT NOT NULL,
PRIMARY KEY("stocknum")
);
I couldn't figure out how to adjust my table or the crawler. I've been at it for hours and I cannot figure out what's going on.