Note

인스타그램 크롤링 (5) - picture_id 본문

etc/Crawling

인스타그램 크롤링 (5) - picture_id

알 수 없는 사용자 2022. 7. 8. 22:02
728x90
# 인스타 picture_id
# www.instagram.com/p/abcd/형태
# abcd 추출
try:
    overlays5 = 'div._ab8w._ab94._ab99._ab9f._ab9k._ab9o > div > div > a'
    picture_id = driver.find_element_by_css_selector(overlays5)    
    picture_id = picture_id.get_attribute('href')
    picture_id = picture_id.split('/')[4]
         
except:
            
	try:
		overlays5 = 'div._ab8w._ab94._ab99._ab9f._ab9k._ab9o > div > div > div > a'
        picture_id = driver.find_element_by_css_selector(overlays5)    
        picture_id = picture_id.get_attribute('href')
        picture_id = picture_id.split('/')[4]

	except:
                
        overlays5 = 'div._ab8w._ab94._ab99._ab9f._ab9k._ab9o > div > div > a:nth-child(2)'
        picture_id = driver.find_element_by_css_selector(overlays5)    
        picture_id = picture_id.get_attribute('href')
        picture_id = picture_id.split('/')[4]
Comments