Giter Club home page Giter Club logo

wikiquote's Introduction

wikiquote

CI Status License Version Black

The wikiquote package for Python (>=3.8) allows you to search and retrieve quotes from any Wikiquote article, as well as retrieve the quote of the day.

Installation

You can install the wikiquote package using, for example, pip:

$ pip install --upgrade wikiquote

Usage

>>> import wikiquote

>>> wikiquote.search('The Matrix')
# ['The Matrix (film)', 'The Matrix Revolutions', 'The Matrix Reloaded', 'The Animatrix']

>>> wikiquote.quotes('The Matrix (film)', max_quotes=2) # max_quotes defaults to 20
# ['Don't think you are, know you are.', 'Fate, it seems, is not without a sense of irony.']

>>> wikiquote.quote_of_the_day() # returns a (quote, author) tuple
# 'Always forgive your enemies; nothing annoys them so much.', 'Oscar Wilde'

>>> wikiquote.qotd() # same as quote_of_the_day()

>>> wikiquote.random_titles(max_titles=3) # max_titles defaults to 20
# ['The Lion King', 'Johannes Kepler', 'Rosa Parks']

>>> wikiquote.supported_languages()
# ['de', 'en', 'es', 'eu', 'fr', 'he', 'it', 'pl', 'pt']

Some article titles will lead to a Disambiguation page (like Matrix), which will raise a DisambiguationPageException exception. Usually this happens because there are many articles matching the search term. When this happens, try using search() first, and then use one of the specific article titles found.

If the article searched for does not exist, and no similar results exist, NoSuchPageException will be raised instead.

When requesting the quote of the day, a MissingQOTDException exception will be raised if the quote of the day could not be extracted from Wikiquote's main page. This usually happens because the page's layout has been changed.

Languages

The wikiquote module currently supports the following languages:

Language ISO 639-1 Code
Basque eu
English en
French fr
German de
Hebrew he
Italian it
Polish pl
Portuguese pt
Spanish es

Use the lang parameter to specify the language (defaults to en):

>>> import wikiquote

>>> wikiquote.quotes('Dune', lang='en')[0]
# 'Parting with friends is a sadness. A place is only a place.'

>>> wikiquote.quotes('Victor Hugo', lang='fr')[0]
# 'Le plus lourd fardeau, c'est d'exister sans vivre.'

>>> wikiquote.quotes('Nueve reinas', lang='es')[0]
# 'Más ofendido estás... menos sospechoso parecés.'

>>> wikiquote.quote_of_the_day(lang='es')
# 'He sospechado alguna vez que la única cosa sin misterio es la felicidad, porque se justifica por sí sola.', 'Jorge Luis Borges'

>>> wikiquote.quotes('Hermann Hesse', lang='de')[0]
# 'Nun, aller höhere Humor fängt damit an, daß man die eigene Person nicht mehr ernst nimmt.'

>>> wikiquote.quote_of_the_day(lang='it')
# "Siamo angeli con un'ala sola. Possiamo volare solo restando abbracciati.", 'Luciano De Crescenzo'

>>> wikiquote.quote_of_the_day(lang='pl')
# 'Boże pomóż mi być takim człowiekiem, za jakiego uważa mnie mój pies.', 'Janusz Leon Wiśniewski'

>>> wikiquote.quotes('José Saramago', lang='pt')[0]
# 'Nem a juventude sabe o que pode, nem a velhice pode o que sabe.'

Specifying an invalid language will result in an UnsupportedLanguageException exception.

Tips

Use random.choice() to select a random quote from an article:

>>> import wikiquote, random

>>> random.choice(wikiquote.quotes('Linus Torvalds'))
# 'WE DO NOT BREAK USERSPACE!'

Caveats

In some cases, wikiquote may fail to retrieve quotes from some articles, or the quote of the day (QOTD). This is due to Wikiquote.org's varying internal article layouts: some quotes may be contained in div elements, others in li, etc. depending on the article and the language.

Developing

Poetry is required to develop wikiquote.

First, make sure you have installed all necessary dependencies, including development dependencies:

$ poetry install

Then, check that all files are correctly formatted, and that the type hints are also correct:

$ poetry run make lint
$ poetry run make install-types
$ poetry run make types

After that, check that all tests pass:

$ poetry run make test

Some tests may be skipped in the QOTD is not available for some languages.

Finally, create a pull request stating your changes.

Changelog

See the CHANGELOG.md file.

License

The wikiquote package is licensed under the MIT License.

wikiquote's People

Contributors

chanchar avatar coreykerchner avatar dependabot[bot] avatar e-gor avatar etkadt avatar federicotdn avatar kevgathuku avatar reala10n avatar salty-horse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wikiquote's Issues

UnboundLocalError: local variable 'txt' referenced before assignment

Since 0.1.7 I keep getting this error:

qts = wikiquote.quotes(qt[0])
File "/var/task/wikiquote/quotes.py", line 57, in quotes
return langs.extract_quotes_lang(lang, html_tree, max_quotes)
File "/var/task/wikiquote/langs/init.py", line 29, in extract_quotes_lang
return lang_dict[lang].extract_quotes(html_tree, max_quotes)
File "/var/task/wikiquote/langs/en.py", line 11, in extract_quotes
q_lst = utils.extract_quotes_li(tree, max_quotes, HEADINGS, WORD_BLACKLIST)
File "/var/task/wikiquote/utils.py", line 151, in extract_quotes_li
quotes_list.append(txt)
UnboundLocalError: local variable 'txt' referenced before assignment

Everything works fine with 0.1.6

Returning "Main Article" links as quotes

I noticed this when trying to get quotes from the Plato page on the English wikiquote.

Python 3.6.0 (default, Jan 12 2017, 01:20:20)
[GCC 4.2.1 Compatible FreeBSD Clang 3.8.0 (tags/RELEASE_380/final 262564)] on freebsd11
Type "help", "copyright", "credits" or "license" for more information.
>>> import wikiquote
>>> wikiquote.quotes('Plato', max_quotes=3)
['Main article: Euthyphro', 'Main article: Apology (Plato)', 'Main article: Crito']

No module named request

ImportError: No module named request

In [3]: import urllib.request
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-3-15bc3377aa0e> in <module>()
----> 1 import urllib.request

ImportError: No module named request

In [4]: from urllib import request
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-4-912f65937d34> in <module>()
----> 1 from urllib import request

ImportError: cannot import name request

In [5]: from urllib import request;
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-5-3063e56997be> in <module>()
----> 1 from urllib import request;

ImportError: cannot import name request

Got this error while importing wikiquote

French language seems to be broken

Hi,

I raised some issues during

1) The tests

File ".../python-wikiquotes-master/wikiquote/langs/fr.py", line 18, in qotd
tree = tree.xpath('div/div')[1].xpath('table/tr/td')[1]

File ".../python-wikiquotes-master/tests/test_quotes.py", line 36, in test_max_quotes_and_lang
self.assertEqual(len(quotes), 8)

2) Grabing

wikiquote.quotes('Dune', lang='fr')
[]

  1. I started to change the code in the fr.py

def qotd(html_tree):
tree = html_tree.get_element_by_id('mf-cdj')

selector = 'div/div/table/tbody/tr'
raw_quote = tree.xpath(selector)[0].text_content().split(u'\xa0')
quote = raw_quote[1].strip()
author = raw_quote[3].split('\n')[0]
return quote, author

I'll try to continue to investigate but sure you can find before me 😃

Cheers,
Cyril

quote_of_the_day errors with some languages : best way to fix ?

Hi

I recently noticed an error throwing from quote_of_the_day() function with 'param lang=fr'.

I also watched french webpage for wikiquote and it havent the ID "mf-qotd" in it. I am not totally sure what could be the best fix regarding the code : better for an exception or is there a more generic id or xpath formula to catch it ?

Based on supported language I have also noted that error for : fr, eu, pl, pt

Tell me if you need more details but I guess it is easily reproductible

thanks for your work I love wikiquote on some of my shells :)

$ wikiquote.quote_of_the_day(lang="fr")
MissingQOTDException: Unable to retrieve quote of the day. This is probably due to a recent change in Wikiquote's main page page layout. Please try again later. If the problem persists, open an issue at: https://github.com/federicotdn/wikiquote
``

Extracting categories from pages

It would be helpful, when using the random_titles() function, to know what categories a page belongs to, along with the quotes.

Do you think it such a functionality will be useful? Either through a separate call to quotes_and_categories() or through a separate categories() call that would perhaps cache the page, assuming a subsequent call to quotes().

If this feels out of scope, I could use a different library to get this information. However, it be nice if I didn't have to fetch a page twice through two different libraries.

French language broken

Hello,
Hello any tips to solve this please ? Could not retrieve french quote.

Thanks for help.
Regards,

Thierry

Initial Update

Hi 👊

This is my first visit to this fine repo, but it seems you have been working hard to keep all dependencies updated so far.

Once you have closed this issue, I'll create seperate pull requests for every update as soon as I find one.

That's it for now!

Happy merging! 🤖

image link for QOD?

Hello,

Is there a way to also get the image link for returned quotes or "quote of the day"?

Thanks

Errore: ImportError: libxslt.so.1:

Buon giorno, stavo provando la tua libreria ma mi da questo erroe:

Traceback (most recent call last):
File "./wikiquote1.py", line 18, in
import wikiquote
File "/home/pi/.local/lib/python3.7/site-packages/wikiquote/init.py", line 1, in
from .quotes import quotes, random_titles, search
File "/home/pi/.local/lib/python3.7/site-packages/wikiquote/quotes.py", line 1, in
import lxml.html
File "/home/pi/.local/lib/python3.7/site-packages/lxml/html/init.py", line 53, in
from .. import etree
ImportError: libxslt.so.1: cannot open shared object file: No such file or directory

ho installato la libreria con:
pip3 install --upgrade wikiquote

Lo script è:

#!/usr/bin/python3
import wikiquote
print(wikiquote.quotes('Dune', lang='en')[0])

Raspbian / lxml

Hello,

I'm not an expert, but I got problem when installing with pip on my raspberry (raspbian lastest version)
First I find it strange :
Collecting lxml<5.0,>=4.2 (from wikiquote)

Then i'm stuck at :
Building wheel for lxml (setup.py) ... \

CPU go to 100%

In the first place i get this error, but after installing python-dev package I get thoses before

root@Raspberry:/home/pi# pip3 install wikiquote
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting wikiquote
Collecting lxml<5.0,>=4.2 (from wikiquote)
Using cached https://files.pythonhosted.org/packages/7d/29/174d70f303016c58bd790c6c86e6e86a9d18239fac314d55a9b7be501943/lxml-4.3.3.tar.gz
Building wheels for collected packages: lxml
Building wheel for lxml (setup.py) ... error
ERROR: Complete output from command /usr/bin/python -u -c 'import setuptools, tokenize;file='"'"'/tmp/pip-install-lx0zqt07/lxml/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-pz3w0jf4 --python-tag cp35:
ERROR: Building lxml version 4.3.3.
Building without Cython.
ERROR: b'/bin/sh: 1: xslt-config: not found\n'
** make sure the development packages of libxml2 and libxslt are installed **

Using build configuration of libxslt
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-armv7l-3.5
creating build/lib.linux-armv7l-3.5/lxml
copying src/lxml/builder.py -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/cssselect.py -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/usedoctest.py -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/ElementInclude.py -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/init.py -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/_elementpath.py -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/pyclasslookup.py -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/doctestcompare.py -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/sax.py -> build/lib.linux-armv7l-3.5/lxml
creating build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/init.py -> build/lib.linux-armv7l-3.5/lxml/includes
creating build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/builder.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/ElementSoup.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/soupparser.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/diff.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/usedoctest.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/html5parser.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/_html5builder.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/clean.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/defs.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/init.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/_diffcommand.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/_setmixin.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/formfill.py -> build/lib.linux-armv7l-3.5/lxml/html
creating build/lib.linux-armv7l-3.5/lxml/isoschematron
copying src/lxml/isoschematron/init.py -> build/lib.linux-armv7l-3.5/lxml/isoschematron
copying src/lxml/etree.h -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/etree_api.h -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/lxml.etree.h -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/lxml.etree_api.h -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/includes/xinclude.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/relaxng.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/xslt.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/schematron.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/c14n.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/htmlparser.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/uri.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/etreepublic.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/config.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/xmlschema.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/dtdvalid.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/xmlerror.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/init.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/xpath.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/xmlparser.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/tree.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/lxml-version.h -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/etree_defs.h -> build/lib.linux-armv7l-3.5/lxml/includes
creating build/lib.linux-armv7l-3.5/lxml/isoschematron/resources
creating build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/rng
copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/rng
creating build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl
copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl
copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl
creating build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
running build_ext
building 'lxml.etree' extension
creating build/temp.linux-armv7l-3.5
creating build/temp.linux-armv7l-3.5/src
creating build/temp.linux-armv7l-3.5/src/lxml
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-6waWnr/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DCYTHON_CLINE_IN_TRACEBACK=0 -Isrc -Isrc/lxml/includes -I/usr/include/python3.5m -c src/lxml/etree.c -o build/temp.linux-armv7l-3.5/src/lxml/etree.o -w
In file included from src/lxml/etree.c:687:0:
src/lxml/includes/etree_defs.h:14:31: fatal error: libxml/xmlversion.h: Aucun fichier ou dossier de ce type
#include "libxml/xmlversion.h"
^
compilation terminated.
Compile failed: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
creating tmp
cc -I/usr/include/libxml2 -c /tmp/xmlXPathInitg9m84jkg.c -o tmp/xmlXPathInitg9m84jkg.o
/tmp/xmlXPathInitg9m84jkg.c:1:26: fatal error: libxml/xpath.h: Aucun fichier ou dossier de ce type
#include "libxml/xpath.h"
^
compilation terminated.


Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?


error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

ERROR: Failed building wheel for lxml
Running setup.py clean for lxml
Failed to build lxml
Installing collected packages: lxml, wikiquote
Found existing installation: lxml 3.7.1
Uninstalling lxml-3.7.1:
Successfully uninstalled lxml-3.7.1
Running setup.py install for lxml ... error
ERROR: Complete output from command /usr/bin/python -u -c 'import setuptools, tokenize;file='"'"'/tmp/pip-install-lx0zqt07/lxml/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-mvdqoozs/install-record.txt --single-version-externally-managed --compile:
ERROR: Building lxml version 4.3.3.
Building without Cython.
ERROR: b'/bin/sh: 1: xslt-config: not found\n'
** make sure the development packages of libxml2 and libxslt are installed **

Using build configuration of libxslt
running install
running build
running build_py
creating build
creating build/lib.linux-armv7l-3.5
creating build/lib.linux-armv7l-3.5/lxml
copying src/lxml/builder.py -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/cssselect.py -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/usedoctest.py -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/ElementInclude.py -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/__init__.py -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/_elementpath.py -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/pyclasslookup.py -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/doctestcompare.py -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/sax.py -> build/lib.linux-armv7l-3.5/lxml
creating build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/__init__.py -> build/lib.linux-armv7l-3.5/lxml/includes
creating build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/builder.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/ElementSoup.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/soupparser.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/diff.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/usedoctest.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/html5parser.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/_html5builder.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/clean.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/defs.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/__init__.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/_diffcommand.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/_setmixin.py -> build/lib.linux-armv7l-3.5/lxml/html
copying src/lxml/html/formfill.py -> build/lib.linux-armv7l-3.5/lxml/html
creating build/lib.linux-armv7l-3.5/lxml/isoschematron
copying src/lxml/isoschematron/__init__.py -> build/lib.linux-armv7l-3.5/lxml/isoschematron
copying src/lxml/etree.h -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/etree_api.h -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/lxml.etree.h -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/lxml.etree_api.h -> build/lib.linux-armv7l-3.5/lxml
copying src/lxml/includes/xinclude.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/relaxng.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/xslt.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/schematron.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/c14n.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/htmlparser.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/uri.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/etreepublic.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/config.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/xmlschema.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/dtdvalid.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/xmlerror.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/__init__.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/xpath.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/xmlparser.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/tree.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/lxml-version.h -> build/lib.linux-armv7l-3.5/lxml/includes
copying src/lxml/includes/etree_defs.h -> build/lib.linux-armv7l-3.5/lxml/includes
creating build/lib.linux-armv7l-3.5/lxml/isoschematron/resources
creating build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/rng
copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/rng
creating build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl
copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl
copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl
creating build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
running build_ext
building 'lxml.etree' extension
creating build/temp.linux-armv7l-3.5
creating build/temp.linux-armv7l-3.5/src
creating build/temp.linux-armv7l-3.5/src/lxml
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-6waWnr/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DCYTHON_CLINE_IN_TRACEBACK=0 -Isrc -Isrc/lxml/includes -I/usr/include/python3.5m -c src/lxml/etree.c -o build/temp.linux-armv7l-3.5/src/lxml/etree.o -w
In file included from src/lxml/etree.c:687:0:
src/lxml/includes/etree_defs.h:14:31: fatal error: libxml/xmlversion.h: Aucun fichier ou dossier de ce type
 #include "libxml/xmlversion.h"
                               ^
compilation terminated.
Compile failed: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
cc -I/usr/include/libxml2 -c /tmp/xmlXPathInit9o69vu7v.c -o tmp/xmlXPathInit9o69vu7v.o
/tmp/xmlXPathInit9o69vu7v.c:1:26: fatal error: libxml/xpath.h: Aucun fichier ou dossier de ce type
 #include "libxml/xpath.h"
                          ^
compilation terminated.
*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
*********************************************************************************
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
----------------------------------------

Rolling back uninstall of lxml
Moving to /usr/lib/python3/dist-packages/lxml
from /usr/lib/python3/dist-packages/~xml
Moving to /usr/lib/python3/dist-packages/lxml-3.7.1.egg-info
from /usr/lib/python3/dist-packages/~xml-3.7.1.egg-info
ERROR: Command "/usr/bin/python -u -c 'import setuptools, tokenize;file='"'"'/tmp/pip-install-lx0zqt07/lxml/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-mvdqoozs/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-lx0zqt07/lxml/

Quote extractor returning bad results

I'm using the new random_titles() feature to find random quotes.

Some of the pages are of plays/TV shows, and those return some unusable results. For example:

  • For The Good Girl, one of the "quotes" returned is the text under the "External Links" section, such as "The Good Girl at Rotten Tomatoes".
  • For The Bedford Diaries, it splits up parts of a quoted dialogue and returns them as individual quotes. e.g. ["Richard: I never said I wouldn't print the article.", "Sarah: You said \"not to worry\"."]

Same quote multiple language

Hi, is it possible to have the same quote in multiple languages?
If there is the ability to do it directly or through a workaround.
Thank you

Novice encountered two exceptions--Certificate verify failed

Hi there, I am a novice of Python. I don't know what to do when I see the information below. Please help, thanks very much!!!

import wikiquote
wikiquote.search('Mark Twain')

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1318, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1400, in connect
server_hostname=server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 401, in wrap_socket
_context=self, _session=session)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 808, in init
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 1061, in do_handshake
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 683, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<pyshell#5>", line 1, in
wikiquote.search('Mark Twain')
File "/Users/Downloads/wikiquote-0.1.5/wikiquote/quotes.py", line 22, in search
data = utils.json_from_url(local_srch_url, s)
File "/Users/Downloads/wikiquote-0.1.5/wikiquote/utils.py", line 31, in json_from_url
res = urllib.request.urlopen(url)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 564, in error
result = self._call_chain(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 756, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1361, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.