티스토리 뷰
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from bs4 import BeautifulSoup
def fGetLinkPage(linkAddress):
driver = webdriver.Chrome()
driver.get(linkAddress)
try:
title1 = driver.find_element_by_tag_name('title')
print("[title]", title1.text)
except :
print("[Excepted]-TITLE")
try:
body1 = driver.find_element_by_tag_name('body')
print("[body]", body1.text)
except :
print("[Excepted-BODY]")
driver.close()
def fGetLinkPage2(linkAddress):
driver = webdriver.Chrome()
driver.get(linkAddress)
try:
print(driver.title)
except :
print("[Excepted]-TITLE")
try:
body1 = driver.find_element_by_tag_name('body')
print("[body]", body1.text)
except :
print("[Excepted-BODY]")
driver.close()
driver = webdriver.Chrome(executable_path=r'C:\Users\Bilient\Documents\PythonProjects\chromedriver.exe')
driver.get("https://www.google.com")
elem = driver.find_element_by_name("q")
elem.send_keys("MM2E")
elem.send_keys(Keys.RETURN)
Items = driver.find_elements_by_css_selector(".yuRUbf")
count = 1
for item1 in Items:
#print(string(item1))
link1 = item1.find_element_by_tag_name("a")
#print(link1.getText())
print(link1.get_attribute('href'))
fGetLinkPage2(link1.get_attribute('href'))
driver.close()
반응형
'SWDesk' 카테고리의 다른 글
[Python] Connecting to Google Drive (2) | 2020.12.26 |
---|---|
[Python] Storing Webpage to PDF (2) | 2020.12.26 |
오늘 조사 자료 - 온톨로지(ontology) (0) | 2020.06.26 |
IFTTT에서 서비스 등록하기 예제 (0) | 2020.05.13 |
[TSDA] Class Description - cTimeProperty (0) | 2020.05.01 |
반응형
250x250
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Hurdles
- 배프
- 아두이노
- image
- 혁신
- 빌리언트
- badp
- Innovations
- 티스토리챌린지
- Video
- 심심풀이
- 치매방지
- 혁신과허들
- arduino
- BSC
- 전압전류모니터링
- 치매
- 오블완
- Innovations&Hurdles
- 둎
- Innovation&Hurdles
- 심심풀이치매방지기
- 전류
- 허들
- ServantClock
- 절연형
- DYOV
- bilient
- 전압
- Decorator
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 28 | 29 | 30 | 31 |
글 보관함