I want to crawl the data site. But something wrong in my code
I want to find why find object is wrong and search in stack overflow but i can't find what's wrong in this code
from bs4 import BeautifulSoup
from pymongo import MongoClient
import requests
from matplotlib import font_manager, rc
client = MongoClient("localhost", 27017)
database = client.datadb
collection = database.datacol
page = requests.get("https://www.worlddata.info/average-income.php")
soup = BeautifulSoup(page.content, 'html.parser')
general_list = soup.find("tr")
#list_of_tr = general_list.find("tr")
for in_each_tr in general_list:
list_of_td0 = general_list.find_all("td")[0]
list_of_td1 = general_list.find_all("td")[1]
general_list = collection.insert_one({"country":list_of_td0.get_text(), "income":list_of_td1.get_text()})
Traceback (most recent call last):
File "C:/Users/SAMSUNG/PycharmProjects/simple/data.py", line 18, in <module>
for in_each_tr in general_list:
TypeError: 'NoneType' object is not iterable