css-selectors

Get text with BeautifulSoup CSS Selector

时光毁灭记忆、已成空白 提交于 2020-08-22 05:12:11
问题 Example HTML <h2 id="name"> ABC <span class="numbers">123</span> <span class="lower">abc</span> </h2> I can get the numbers with something like: soup.select('#name > span.numbers')[0].text How do I get the text ABC using BeautifulSoup and the select function? What about in this case? <div id="name"> <div id="numbers">123</div> ABC </div> 回答1: In the first case, get the previous sibling: soup.select_one('#name > span.numbers').previous_sibling In the second case, get the next sibling: soup

CSS selectors apply style to all images except the first one

不羁的心 提交于 2020-08-19 06:18:20
问题 I thought I could do this with advanced CSS selectors, but struggling. I have a JS Fiddle here with the below example Basically, how can I target every image here, except the first one? I don't want to use classes or IDs, I just want to use advanced selectors, if possible. So something like .entry-content img:first-child (although I know that wouldn't work) <div class='entry-content'> <div> <img src='http://placedog.com/400/300'/> </div> <div> <img src='http://placedog.com/400/300'/> </div>

Python - Tor Browser through Firefox, unable to click button

試著忘記壹切 提交于 2020-08-17 08:20:51
问题 So i have been trying to access a certain site (dumpert.nl) through Tor Browser as proxy via Firefox. The reason I am using Tor Browser is so I can enter the website with a different IP address every time I enter the website. I know this is possible but I have not yet found the way to do this. I have found multiple ways to do this, but they have not (yet) worked for me. Help is wanted on this part aswell. The real problem is I am having trouble with the Accept Cookie page of this website.

How to target specific text content in a paragraph which contains multiple line breaks?

你。 提交于 2020-08-11 07:32:38
问题 So here is the weird thing I am clueless on.. Below is the sample snippet of the HTML, <p>This is a paragraph with <br><br> two weird line breaks <br><br> and that too TWICE!</p> Now the issue is, I want to apply CSS to the text This is paragraph OR the content after first-double line breaks. I tried br + br or nth-selectors, all css selectors I could think of, but it didn't worked out. Tricky part is, I do not want to do by javascript, or else I would have done it easily accompanied by

Scrapy Last Page is not null and after page 146 last page is showing again

江枫思渺然 提交于 2020-08-09 08:14:43
问题 The website has 146 pages with words but after page 146 the last page is showing again. ` if next_page is not None: yield response.follow(next_page, callback = self.parse)` With this method sprider is not stoping at page 146 and it continues because page 147,148,149..is same as page 146. I tried to use for loop but that not worked. Also, I tried to take the value in next page button and break the function with next_extract. By the way output of next_extract is ['kelimeler.php?s=1']and the

::slotted CSS selector for nested children

て烟熏妆下的殇ゞ 提交于 2020-08-05 05:57:19
问题 The CSS ::slotted selector selects children of the <slot> element. however, when trying to select grandchildren like with ::slotted(*) , ::slotted(*) * , or ::slotted(* *) , the selector doesn't seem to take effect. class MyElement extends HTMLElement { constructor() { super(); const shadowRoot = this.attachShadow({mode: 'open'}) shadowRoot.innerHTML = ` <style> ::slotted(*) { display: block; border: solid blue 1px; padding: 3px; } ::slotted(*) span { display: block; border: solid red 1px;

How to target direct text and not text within tags?

老子叫甜甜 提交于 2020-08-04 06:02:27
问题 Is there a way to only target the direct text within a <h1> -Tag? Here is an example on what I want to do: <h1>I want to select this text with a css selector <small>but not this text</small></h1> This does not seem to work: h1:not(small) Is it even possible? 回答1: h1:not(small) Your selector h1:not(small) doesn't work because it says this: Target all h1 elements that are not small elements. It's that same as using the h1 selector by itself. h1 :not(small) You would have been closer with h1

How to find elements that do not include a certain class name with selenium and python

橙三吉。 提交于 2020-08-02 16:22:56
问题 I want to find all the elements that contain a certain class name but skip the ones the also contain another class name beside the one that i am searching for I have the element <div class="examplenameA"> and the element <div class="examplenameA examplenameB"> At the moment i am doing this to overcome my problem: items = driver.find_elements_by_class_name('examplenameA') for item in items: cname = item.get_attribute('class') if 'examplenameB' in cname: pass else: rest of code I only want the

How to find elements that do not include a certain class name with selenium and python

柔情痞子 提交于 2020-08-02 16:22:16
问题 I want to find all the elements that contain a certain class name but skip the ones the also contain another class name beside the one that i am searching for I have the element <div class="examplenameA"> and the element <div class="examplenameA examplenameB"> At the moment i am doing this to overcome my problem: items = driver.find_elements_by_class_name('examplenameA') for item in items: cname = item.get_attribute('class') if 'examplenameB' in cname: pass else: rest of code I only want the

CSS Selector compare 2 attributes

六月ゝ 毕业季﹏ 提交于 2020-07-31 03:41:27
问题 I'm looking for a way to build a selector that would match where two attributes have the same value, but can't find a syntax. Is this possible? How? What I hoped would work: [data-valueA=data-valueB] When I know valueA and valueB ahead of time, I could do: [data-valueA="knownValueForA"][data-valueB="knownValueForB"] {} But I don't know the values and aren't concerned with them in this case, just knowing when they are the same. Here's a fiddle to explore with: https://jsfiddle.net/rainabba