Chrome dirver 크롤링_1_수정(url추가)
조회수 1388회
Problem_1
url ='https://play.google.com/store/apps/details?id=tools.photo.hd.camera&hl=en'
title = driver.find_element_by_xpath('//title')
print(title.get_attribute('content'))
이 코드의 결과로 None 나옵니다. 아무것도 찾아오지를 못합니다.
Problem_2
url ="'https://play.google.com/store/apps/details?id=tools.photo.hd.camera&hl=en'"
driver.get(url)
page = driver.page_source
soup = BeautifulSoup(page, "html.parser")
table = soup.find("div", class_="id-app-title")
print("App name: ", table.string)
AttributeError: 'NoneType' object has no attribute 'string' 라는 에러메세지로 인해서 requrests 이용하여 코드를 조금 변경했습니다
page = requests.get(url).text
soup = BeautifulSoup(page, "html.parser")
table = soup.find("div", class_="id-app-title")
print("App name: ", table)
그래서 결과를 뽑아보니 App name: None 이라고 나옵니다 ㅠ 왜 계속 내용을 뽑아오지 못하고 있는걸까요 예전에 사람인 API를 통해서 했을때는 div 클래스 이름만 맞추면 잘 뽑아 왔는데 google플레이 스토어에서는 div class 이름을 매칭을 시켜도 다 none 값이 나옵니다 ㅜㅠㅜ
-
(•́ ✖ •̀)
알 수 없는 사용자
1 답변
-
자세히 보니 class 값등이 고정이네요.
import requests import bs4 contents = requests.get('https://play.google.com/store/apps/details?id=tools.photo.hd.camera&hl=en').content bs = bs4.BeautifulSoup(contents, 'html.parser') text = bs.find('div', attrs={'jsname':"sngebd"}) print(text) <div jsname="sngebd">HD camera lets you easily shoot HD photos and videos, and offers beautiful filters, and panorama photo mode! 🎊🎉💯<br/><br/>📷 <b>Features:</b><br/>* Optical / digital zoom, tap to focus, focus halo display<br/>* AF mode (infinity, Macro )<br/>* White Balance ( Auto, Fluorescent, white, daylight, cloudy )<br/>* Countdown pictures<br/>* Set the photo size<br/>* Record the shooting location information<br/>*Adjust exposure<br/>* View mode ( sports, night, sunset, party )<br/>*The front and the rear camera toggle<br/>* Shoot and produce a panoramic photo, take immersive panorama<br/>* Viewfinder display sensor can capture the full screen, and not crop the image<br/>* Panorama mode requires the use of a gyro sensor<br/>* For Android 4.0 and higher versions of phones and tablets<br/><br/>------------------<br/>💎 <b>Disclaimer:</b><br/>This app is based on native android camera code and licensed under the Apache License.<br/>Apache Licens: http://www.apache.org/licenses/LICENSE-2.0.html</div>
- 리뷰는 자바스크립트를 이용해서 동적으로 작업합니다. requests 만으로는 어려우니 selenium을 이용하세요. 정영훈 2019.12.4 11:34
- 현재 selenium Chromedriver를 사용하고 있습니다. 현재 requests와 selenium을 두 버전으로 만들어서 만들어 보고 있습니다. 모델은 github에서 가져온 코드를 이용하고 있는데 결과값이 나오지 않아서 애먹고 있었어요 알 수 없는 사용자 2019.12.4 13:38
- 아 죄송하지만 attrs가 어떤것을 뜻하는지 알 수 있을까요 알 수 없는 사용자 2019.12.4 13:45
- https://www.crummy.com/software/BeautifulSoup/bs4/doc/#attrs 문서를 읽어보세요 정영훈 2019.12.4 23:21
댓글 입력