#네이버 검색어 URL 만들기
from bs4 import BeautifulSoup
import urllib.parse
import urllib.request
file = open("C:/Users/eyeden-FF14/Desktop/Auction/all_keywords.txt", 'r' )
Food_keyword_list = open("C:/Users/eyeden-FF14/Desktop/Food_keyword_list.txt", 'w' , encoding='utf-8' )
keywords = file.readlines()
file.close()
Naver_first_URL = 'https://m.search.naver.com/search.naver?query='
Naver_behind_URL = '&where=m&sm=mtp_hty'
for i in keywords :
a = i.replace("\n", "")
b = str(a)
c = urllib.parse.quote(b) #한글 키워드를 utf-8로 변환
URL = Naver_first_URL + c +Naver_behind_URL
Food_keyword_list.write(URL + '\n')
Food_keyword_list.close()
#네이버키워드 추천검색어 뽑기
import urllib.request
import urllib.parse
from bs4 import BeautifulSoup
file = open("C:/Users/eyeden-FF14/Desktop/Food_keyword_list.txt", 'r' , encoding='utf-8')
outcome = open("C:/Users/eyeden-FF14/Desktop/Food_recommended_keyword_list.txt", 'w', encoding='utf-8')
urls = file.readlines()
for page in urls[0:260] :
url = page.replace("\n", "")
f = urllib.request.urlopen(url)
html = f.read()
bs = BeautifulSoup(html, 'html.parser')
keywords = bs.find_all("a", class_="basic_show")
for i in keywords :
outcome.write(str(i) + '\n')
outcome.close()
'Python' 카테고리의 다른 글
[파이썬3] find_element_by_css_selector 확인방법 (0) | 2017.01.23 |
---|---|
[셀레니움] 테스트 (0) | 2017.01.23 |
[네이버] 섹션 크롤링3 (0) | 2017.01.18 |
[파이썬3] 한글 교정 (0) | 2017.01.17 |
[네이버] 옥션 검색어를 통한 추천검색어 크롤링(모바일) (0) | 2017.01.17 |
댓글