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.