Day 72 Of 100DaysOfCode: CSS Locator
Durga Pokharel
Posted on March 10, 2021
This is my 72th day of #100DaysOfCode and #python learning. Like yesterday today also continue to learned more about web scraping in the topics text extraction, follow() method, spider, weaving the web, inspecting elements from Datacamp.
Xpath and CSS locator in python
from scrapy import Selector
# Create a selector object from a secret website
sel = Selector( text = html)
# Select all hyperlinks of div elements belonging to class "course-block"
course_as = sel.css( 'div.course-block > a' )
# Selecting all href attributes chaining with css
hrefs_from_css = course_as.css( '::attr(href)' )
# Selecting all href attributes chaining with xpath
hrefs_from_xpath = course_as.xpath( './@href')
Day 72 Of #100DaysOfCode and #Python
— Durga Pokharel (@mathdurga) March 10, 2021
Web-scraping(CSS locator and changing and responses) From https://t.co/fBZgTteSh7Datacamp#WomenWhoCode #CodeNewbie #100DaysOfCode #beginner #DEVCommunity pic.twitter.com/yuC9PoDCMI
💖 💪 🙅 🚩
Durga Pokharel
Posted on March 10, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.