2

When I run this xpath expression //tr[42]/td//span/./following-sibling::a[1]/@href on two different systems, I get two different results.

On Ubuntu 14.04.2 LTS i get ["javascript:__doPostBack('datagrid_results$_ctl44$_ctl1','')"]

On rehel fedora 2015.03 (Amazon Linux AMI) i get []

Here is the full HTML source and here is python source code that you can run like so

python xpath.py file.html '//tr[42]/td//span/./following-sibling::a[1]/@href'

Also you can preview what the HTML looks like (after pasting the code), using this.

Besides the above system differences, the following are the same on both systems.

Python 2.7.9

LXML 3.5

Packages on Ubuntu

  • libxslt, version 1.1.28-2build1
  • libxml2, version 2.9.1+dfsg1-3ubuntu4.5

Packages on RHEL Fedora

  • libxml2, version 2.9.1, release 3.1.35.amzn1
  • libxslt, version 1.1.28, release 5.12.amzn1

On ubuntu server i have the package python-lxml 3.3.3-1ubuntu0.1 , but for some reason I could not find it on the Fedora server

>> yum list installed | grep lxml
>> rpm -qa | grep lxml
>> Sudo yum install python-lxml
Loaded plugins: priorities, update-motd, upgrade-helper
959 packages excluded due to repository priority protections
No package python-lxml available.
Error: Nothing to do

Let me know if more information needs to be provided.

Fuchida
  • 428
  • 6
  • 16
  • Wild guess time... Did you download from your browser on the two machines or test the exact file? The web site may have given different data based on the browser version. – tdelaney Nov 18 '15 at 21:20
  • I assume you used 'lxml.html` which attempts to clean up invalid xml for lxml. Maybe different versions do the clean up differently. – tdelaney Nov 18 '15 at 21:22
  • @tdelaney I tested the exact file, and when downloading from site I anchor the user agent to Chrome 46. And yes I am using lxml.html. – Fuchida Nov 19 '15 at 21:04
  • Darn. it was a wild guess on my part! You could save the lxml doc on both systems and compare to see if there are differences. But its all grasping at straws at this point. – tdelaney Nov 19 '15 at 21:21

0 Answers0