Posts

Showing posts with the label lxml

beautifulsoup for looping and getting text and Href

Image
Clash Royale CLAN TAG #URR8PPP beautifulsoup for looping and getting text and Href Im in a bit of a quinch here: its an ASP site which is really messy that I am trying to get data from: Im trying to use a FOR loop to get an href and the text of all the rows of the 4th table that is on the site, so I first did: table = soup.findAll('table')[3] Then from this table I need to get all text inside the tags and the href's of the inside. i tried something like this: for product in table.findAll('tbody'): product_title = product.find('tr').text product_link = product.find('a')['href'] print (product_title, product_link) But I get nothing in return... :( Can you show a print of product ? – Rakesh 7 mins ago product What does your HTML document look like? –...

python lxml loop on match get next entry

Image
Clash Royale CLAN TAG #URR8PPP python lxml loop on match get next entry I'm using LXML to query multiple XML files containing data elements on various products. This section of code is taking a list of missing product_ids and querying the XML files for the data elements for the products. One of my core issues is that every product_id obtained through xpath is checked against every item in the list products_missing_from_postgresql , which takes forever (hours) How do I restart the for entry in entries loop when a match is found? Maybe this isn't the right question...if not what is the right question? for product_number in products_missing_from_postgresql: try: for entry in entries: product_id = entry.xpath('@id')[0] if product_id != product_number: print('************************') print('current product: ' + product_id) print('no match: ' + product_number) print('*********...

Can't install python lxml (and libxml2) on windows

Image
Clash Royale CLAN TAG #URR8PPP Can't install python lxml (and libxml2) on windows I'm trying to install lxml on windows (pip install lxml) but i keep getting following error: ***** Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed? **************************************************************************** Command "C:Python34python.exe -c "import setuptools, tokenize;__file__='C:\Us ers\meme\AppData\Local\Temp\pip-build-m_doxfaj\lxml\setup.py';exec(comp ile(getattr(tokenize, 'open', open)(__file__).read().replace('rn', 'n'), __fi le__, 'exec'))" install --record C:UsersmemeAppDataLocalTemppip-ekkhc0id -recordinstall-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:UsersmemeAppDataLocalTemppip-build-m_doxfajlxml I've tried to download a binary files for windows from here (ftp://ftp.zlatkovic.com/libxml/) and adding them to path but it doesn'...