DEV Community

Durga Pokharel
Durga Pokharel

Posted on

4 1

Day 72 Of 100DaysOfCode: CSS Locator

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')
Enter fullscreen mode Exit fullscreen mode

Day 72 Of #100DaysOfCode and #Python
Web-scraping(CSS locator and changing and responses) From https://t.co/fBZgTteSh7Datacamp#WomenWhoCode #CodeNewbie #100DaysOfCode #beginner #DEVCommunity pic.twitter.com/yuC9PoDCMI

— Durga Pokharel (@mathdurga) March 10, 2021

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay