Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. # Selector - [[xpath]] ### name() <code py> data_product_line = li.xpath( './/div[@*[name() = "data-product-line"]]/@*[2]' ).extract_first() </code> ### fake_useragent 사용 <code py> %load_ext lab_black import requests from scrapy import Selector from fake_useragent import UserAgent ua = UserAgent(verify_ssl=False) headers = {"user-agent": ua.random} resp = requests.get(url, headers=headers) sel = Selector(resp) </code> ``` url = 'https://www.daks.co.kr/product.do?cmd=getProductDetail&PROD_CD=DMJU0B001K2' driver.get(url) selector = Selector(text=driver.page_source) name = selector.xpath('//*[@id="contents"]/div[1]/form[2]/div[1]/h3').extract_first() name ``` ``` '<h3 class="prod-name">\n\t\n \n\t<!-- 상품명 -->\n\t[DAKS MEN] [이탈리아 LIMONTA 수입원단] 카키 펀칭배색 긴팔캐주얼점퍼 \n\n\n</h3>' ``` ``` url = 'https://www.daks.co.kr/product.do?cmd=getProductDetail&PROD_CD=DMJU0B001K2' driver.get(url) selector = Selector(text=driver.page_source) name = selector.xpath('//*[@id="contents"]/div[1]/form[2]/div[1]/h3/text()').extract_first() name ``` ``` '\n\t\n \n\t' ``` open/selector.txt Last modified: 2024/10/05 06:15by 127.0.0.1