-1
我怎麼能提高我在Python代碼,如果我用了很多行類似下面的改進建議這個Python代碼
post_title_tag = soup.find("h1", {"id": "post-title"})
if post_title_tag is None:
return
在此功能
def get_post_data(url):
browser.get(url)
html_source = browser.page_source
soup = BeautifulSoup(html_source)
post_title_tag = soup.find("h1", {"id": "post-title"})
if post_title_tag is None:
return
description_tag = soup.find("p", class_="description")
if description_tag is None:
return
datetext_span = description_tag.find("span")
if datetext_span is None:
return
這屬於codereview:http://codereview.stackexchange.com/ –