강의

멘토링

커뮤니티

Inflearn Community Q&A

tdj000004541's profile image
tdj000004541

asked

Free Python Course (Usage Part 3) - Web Scraping (5 hours)

BeautifulSoup4 Utilization 2-1 (Coupang)

url 에러? (\UXXXXXXXX escape)

Written on

·

297

0

안녕하세요 선생님 쿠팡 url를 가져오는 과정에서 문제가 생긴 것 같습니다.

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

이 에러가 자꾸 뜨면서 실행이 안되는데요ㅠㅠ 역슬래시가 아니고 슬래시가 사용된 건데 왜 뜨는지 정말 모르겠네요...ㅠㅠ

구글링해도 역슬러시를 두 개 써봐라, raw string 설정을 해봐라 등등이 나오는데 이 url과는 전혀 상관없는거 같아서요

혹시 아신다면 답변 부탁드립니다! 아래는 제 코드입니다.

import requests
from bs4 import BeautifulSoup

url = 'https://www.coupang.com/np/search?q=%EB%85%B8%ED%8A%B8%EB%B6%81&channel=user&component=&eventCategory=SRP&trcid=&traid=&sorter=scoreDesc&minPrice=&maxPrice=&priceRange=&filterType=&listSize=36&filter=&isPriceRange=false&brand=&offerCondition=&rating=0&page=2&rocketAll=false&searchIndexingToken=1=6&backgroundColor='
res = requests.get(url)
res.raise_for_status()

soup = BeautifulSoup(res.text, 'lxml')

print(res.text)
웹 스크래핑seleniumpython웹-크롤링

Answer

This question is waiting for answers
Be the first to answer!
tdj000004541's profile image
tdj000004541

asked

Ask a question