The easiest way to crawl HTML tables is to use pandas.read_html(url). For the following URL, I get all its tables
import pandas as pd
url="http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PTO1&Sect2=HITOFF&d=PALL&p=1&u=%2Fnetahtml%2FPTO%2Fsrchnum.htm&r=1&f=G&l=50&s1=3944788.PN.&OS=PN/3944788&RS=PN/3944788"
df=pd.read_html(url)
From the above URL, I just want this specific information.
Current U.S. Class: 235/54F
Given the above dfas a list, I wrote the following code to get this specific information
myitem="Current U.S. Class:"
for i in range(len(df)):
if myitem in str(df[i]):
ClassTitle=''.join(df[i][0])
ClassNumber=''.join(df[i][1])
if ';' in ClassTitle:
ClassTitle=ClassTitle.rsplit(':')
print(ClassTitle[0])
if ';' in ClassNumber:
ClassNumber=ClassNumber.rsplit(';')
if ',' in ClassTitle:
ClassTitle=ClassTitle.rsplit(',')
print(ClassTitle[0])
if ',' in ClassNumber:
ClassNumber=ClassNumber.rsplit(',')
But it sometimes is excellent for a URL-addresses, and sometimes also includes other information about the class, and Current CPC Classand Current International Class. I also tried BeautifulSoapusing a function View Page Source, but I am confused to mention the class.
source
share