Skip to content

Instantly share code, notes, and snippets.

@DamianZaremba
Created April 13, 2013 11:04
Show Gist options
  • Save DamianZaremba/5377958 to your computer and use it in GitHub Desktop.
Save DamianZaremba/5377958 to your computer and use it in GitHub Desktop.
Get Lenovo warranty status
import urllib
import urllib2
from BeautifulSoup import BeautifulSoup
url = 'http://support.lenovo.com/templatedata/Web%20Content/JSP/' \
'warrantyLookup.jsp'
data = urllib.urlencode({'sysSerial' : 'xxxxxx'})
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
soup = BeautifulSoup(response.read())
form = soup.findAll('form', {'id': 'form1'})[0]
table1 = form.findAll('table')[0]
table2 = table1.findAll('table')[0]
table3 = table2.findAll('table')[1]
cols1 = table3.findAll('tr')[0].findAll('td')
cols2 = table3.findAll('tr')[1].findAll('td')
cols3 = table3.findAll('tr')[4].findAll('td')
cols4 = table3.findAll('tr')[5].findAll('td')
if cols1[0].text == "Product ID:":
print "Product: %s " % cols2[0].text
if cols1[2].text == "Type-Model:":
print "Type: %s " % cols2[2].text
if cols1[4].text == "Serial number:":
print "Serial: %s " % cols2[4].text
if cols3[0].text == "Location:":
print "Warranty Location: %s " % cols4[0].text
if cols3[2].text == "Expiration date:":
print "Warranty Expiration: %s " % cols4[2].text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment