资源:https://www.youtube.com/watch?v=ng2o98k983k
from bs4 import BeautifulSoup
import requests
import csv
source = requests.get("https://coreyms.com/").text
soup = BeautifulSoup(source, 'lxml')
csv_file = open('scraping_coreyms.csv', 'w')
csv_writer = csv.writer(csv_file)
csv_writer.writerow(['headline', 'summary', 'video_link'])
for article in soup.find_all('article'):
headline = article.h2.a.text
summary = article.find('div', class_="entry-content").p.text
try:
vid_src = article.find('iframe', class_="youtube-player")['src']
# To get a list of sections of the youtube video address
vid_id = vid_src.split('/')[4]
# Get the part of address that comes before the question mark - that's