본문 바로가기
나를 위한 코드

링크 가져오기 (셀레니움, 뷰티풀숩)

by 라나나 2023. 4. 16.
728x90

셀레니움

 
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager

url = ''
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
chrome_options.add_experimental_option("excludeSwitches", ["enable-logging"])
service = Service(executable_path=ChromeDriverManager().install())
driver = webdriver.Chrome(service=service, options=chrome_options)
driver.implicitly_wait(10)

driver.get(url)
 

 

뷰티풀숩

 
import requests
from bs4 import BeautifulSoup

url = ''
response = requests.get(url)
print(response.status_code)

if response.status_code == requests.codes.ok:

        html = response.text

        file = open('r.txt','w', encoding="UTF-8")
        file.write(html)
        file.close()
 

 

728x90

댓글