python - sel.css selectors :split into two sentences -


i have question: how split 2 sentences?

here original code

 sel = selector(response)  links = sel.css("div#bargains > article.box h1 > em > a::attr(href)").extract() 

and because want scape infomation,so rewrite this:

 sel = selector(response)  sites = sel.css("div#bargains > article.box h1 > em ")  site in sites:     link = sel.css("a::attr(href)").extract()     title = sel.css("a::text").extract() 

but did not work,it catch information don't want

i know code below not correct,i want ask how express '>' in sel.css in seperate line

link = sel.css("> a::attr(href)").extract()  

please guide me.thank you

scrapy does support "relative" selector syntax. problem sel variable reusing inside loop iterations, you're selecting whole document.

your code should rewritten instead:

sel = selector(response) links = sel.css("div#bargains > article.box h1 > em > a") link_element in links:     link = link_element.css("::attr(href)").extract()     title = link_element.css("::text").extract() 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -