Comments (5)
It's a bug on my side. I will fix it. Thanks for the report.
from selectolax.
@Mancuerna You can try now, but you need to install selectolax from GitHub.
I will add some flexibility to the text functionality before releasing it to PyPi.
from selectolax.
I'm having the same problem with the latest fix. Here you have a Pastebin with the code I'm using to test it (sorry for not writing it here but Github's parser is messing it up).
As you can see the beautifulsoup4
print is the proper one while selectolax
is only printing the text of the first element inside the div
.
from selectolax.
Your second example is a bit different, that's why I wanted to add additional functionality.
In [1]: from selectolax.parser import HTMLParser
In [2]: html = '<div class="post-contents"> <p><a href="/testtest" rel="5" class="quote">#5</a> <a href="testtest" rel="2" class="quote">#2</a> <a href="testtest rel="4" class="qu
...: ote">#4</a> testtesttesttesttest.</p> </div>'
...: selector = "div.post-contents p"
...:
In [3]: for node in HTMLParser(html).css(selector):
...: print(node.text(deep=False))
...:
testtesttesttesttest.
In [4]: html = '<div class="post-contents"><p><strong><em>Night School Studio</em></strong>, estudio responsable de ' \
...: '<em>Oxenfree</em> (una de las sorpresas del año pasado que pasó desapercibida tanto para prensa como ' \
...: 'comunidad), ha anunciado su próximo título, <strong><em>Afterparty</em></strong>.</p></div> '
In [5]:
In [5]: for node in HTMLParser(html).css("div.post-contents"):
...: print(node.text())
...:
Night School Studio, estudio responsable de Oxenfree (una de las sorpresas del año pasado que pasó desapercibida tanto para prensa como comunidad), ha anunciado su próximo título, Afterparty.
I changed the behavior of text
, now it's a function, not an attribute.
So, for the first example you need to use deep=False, otherwise, it will include all text from a
tags.
Can you try now? Works for me.
from selectolax.
It works like a charm now. Thank you for your time <3
from selectolax.
Related Issues (20)
- Node.child should be named Node.first_child ? HOT 2
- Awful text parsing issue HOT 6
- Release wheel for python 3.12 HOT 5
- Tags out of order in returned list when using css to specify multiple tags HOT 5
- What is/was the format for the pages/pages.json file? HOT 1
- Wheels for aarch64 platform (AWS Graviton2 arm64) HOT 3
- Lexbor seems to be the preferred choice? HOT 9
- Why does selectolax ship Cython as install dependency? HOT 6
- Does `selectolax` support contains query ? HOT 3
- Return an error when trying to decompose a node with `html` tag HOT 4
- Bug Found within Lexbor HOT 2
- LexborHTMLParser find by text HOT 1
- Memory leak when using LexborHTMLParser HOT 1
- Segmentation fault with Lexbor engine HOT 2
- Allow regular expressions in `text_contains` / `any_text_contains` HOT 2
- Adding AdvancedHTMLParser to benchmark HOT 2
- Weird issue in rendering HTML HOT 4
- Cannot import name modest HOT 1
- ModuleNotFoundError: No module named 'selectolax.parser'; 'selectolax' is not a package HOT 1
- Best way to handle content not found? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from selectolax.