Crawling Practice (feat.Python)

Crawling Practice with the topic Drama

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
kw = input('키워드를 입력하세요 : ')
url = f'https://search.naver.com/search.naver?where=nexearch&sm=top_sug.pre&fbm=1&acr=1&acq=%EA%B2%80%EC%9D%80&qdt=0&ie=utf8&query={kw}'
response = requests.get(url)
html = BeautifulSoup(response.text, 'html.parser')
html.select('a')

for txt in html.select('a'):
if kw in txt.text:
if ('cafe' in txt.attrs['href']) or ('blog' in txt.attrs['href']):
print(txt.text, txt.attrs['href'])
else:
pass
else:
pass

drama = input('드라마 이름을 입력하세요 : ')
url = f'https://search.daum.net/search?w=tot&DA=YZR&t__nil_searchbox=btn&sug=&sugo=&sq=&o=&q={drama}'
response = requests.get(url)
html = BeautifulSoup(response.text, 'html.parser')
drama_summary = html.select('dd.cont')[0].text
print(f'드라마 줄거리 : {drama_summary}')
print()

print(' 배역 배우')
print(' ------------------')
for cont in html.select('div#tv_casting li')[1:]:
print(cont.text)
  • I used the crawling python code to print drama info.
  • 무단복제 금지(Against unauthorized copies)