Skip to content

feedparservspyquery

NOASSERTION 105 9 2,351
14.7 million (month) Jun 15 2007 6.0.12(2025-09-10 13:33:58 ago)
2,381 5 55 NOASSERTION
Dec 05 2008 2.0 million (month) 2.0.1(2024-08-30 08:12:22 ago)

feedparser is a Python module for downloading and parsing syndicated feeds. It can handle RSS 0.90, Netscape RSS 0.91, Userland RSS 0.91, RSS 0.92, RSS 0.93, RSS 0.94, RSS 1.0, RSS 2.0, Atom 0.3, Atom 1.0, and CDF feeds. It also parses several popular extension modules, including Dublin Core and Apple’s iTunes extensions.

To use Universal Feed Parser, you will need Python 3.6 or later. Universal Feed Parser is not meant to run standalone; it is a module for you to use as part of a larger Python program.

feedparser can be used to scrape data feeds as it can download them and parse the XML structured data.

PyQuery is a Python library for working with XML and HTML documents. It is similar to BeautifulSoup and is often used as a drop-in replacement for it.

PyQuery is inspired by javascript's jQuery and uses similar API allowing selecting of HTML nodes through CSS selectors. This makes it easy for developers who are already familiar with jQuery to use PyQuery in Python.

Unlike jQuery, PyQuery doesn't support XPath selectors and relies entirely on CSS selectors though offers similar HTML parsing features like selection of HTML elements, their attributes and text as well as html tree modification.

PyQuery also comes with a http client (through requests) so it can load and parse web URLs by itself.

Highlights


css-selectors

Example Use


```python import feedparser # the feed can be loaded from a remote URL data = feedparser.parse('http://feedparser.org/docs/examples/atom10.xml') # local path data = feedparser.parse('/home/user/data.xml') # or raw string data = feedparser.parse('...') # the result dataset is a nested python dictionary containing feed data: data['feed']['title'] ```
```python from pyquery import PyQuery as pq # this is our HTML page: html = """ Hello World!

Product Title

paragraph 1

paragraph2

$10
""" doc = pq(html) # we can use CSS selectors: print(doc('#product .price').text()) "$10" # it's also possible to modify HTML tree in various ways: # insert text into selected element: print(doc('h1').append('discounted')) "

Product Titlediscounted

" # or remove elements doc('p').remove() print(doc('#product').html()) """

Product Titlediscounted

$10 """ # pyquery can also retrieve web documents using requests: doc = pq(url='http://httpbin.org/html', headers={"User-Agent": "webscraping.fyi"}) print(doc('h1').html()) ```

Alternatives / Similar


Was this page helpful?