из bs4 импорт Запрос на импорт BeautifulSoup
r = запросы.get ('https://www.yelu.in/category/advertising') суп = BeautifulSoup (r.text,' lxml ')
для ссылок в супе.find_all ('a', класс _ = 'm_company_link'): href = links ['href']
headers = {'User-Agent': 'Googleboat'}
r = requests.get("https://www.yelu.in/"+href,headers = headers)
soup = BeautifulSoup(r.text,'lxml')
company = {
"company_name" : soup.select_one('#company_name').text,
"address" : soup.select_one('div.text.location').text,
"phone" : soup.select_one('div.text.phone').text,
"mobile_phone" : soup.find('div',string = "Mobile
phone").find_next_sibling('div').text,
"fax": soup.find('div',string = "Fax").find_next_sibling('div').text,
"website" : soup.find('div',string =
"Website").find_next_sibling('div').text,
"year" :soup.find('span',string = "Establishment year").next_sibling,
"employees" :soup.find('span',string = "Employees").next_sibling,
"manager" :soup.find('span',string = "Company manager").next_sibling
}
print(company)
я получаю эту ошибку ниже "Traceback (последний вызов был последним): файл" C:\ Python27 \ yelu.py ", строка 14, в" company_name ": soup.select_one ('# company_name'). Text, AttributeError: у объекта 'NoneType' нет атрибута 'text'
"