последовал совету, и я смог передать исходную ошибку, спасибо вам всем до сих пор :) Я почти там, где хочу быть. Кажется, у меня все еще огромный пробел в знаниях, когда дело доходит до отступов. вы, ребята, поистине жемчужина для сообщества программистов, большое вам спасибо :)
Here is the current code that has passed those errors and its down to a warning, and not extracting anything.
import requests
from bs4 import BeautifulSoup
import pandas as pd
url = 'https://dc.urbanturf.com/pipeline'
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
pipeline_items = soup.find_all('div', attrs={'class': 'pipeline-item'})
rows = []
columns = ['Listing Title', 'Listing url', 'listing image url', 'location', 'Project type', 'Status', 'Size']
for item in pipeline_items:
# title, image url, listing url
listing_title = item.a['title']
listing_url = item.a['href']
listing_image_url = item.a.img['src']
for p_tag in item.find_all('p'):
if not p_tag.h2:
if p_tag.text == 'Location:':
p_tag.span.extract()
property_location = p_tag.text.strip()
elif p_tag.span.text == 'Project type:':
p_tag.span.extract()
property_type = p_tag.text.strip()
elif p_tag.span.text == 'Status:':
p_tag.span.extract()
property_status = p_tag.text.strip()
elif p_tag.span.text == 'Size:':
p_tag.span.extract()
property_size = p_tag.text.strip()
row = [listing_title, listing_url, listing_image_url, property_location, property_type, property_status, property_size]
rows.append(row)
df = pd.Dataframe(rows, columns=columns)
df.to_excel('DC Pipeline Properties.xlsx', index=False)
print('File Saved')
ошибка, которую я получаю, заключается в следующем: я использую pycharm 2020.2, может быть, это плохой выбор? 1005 * row = [название_список, url_перечисления, URL_образа_предложения, расположение_свойства, тип_свойства, статус_свойства, размер_свойства] NameError: имя 'расположение_свойства' не определено