我有 2 种类型的 URL
第一个在网址末尾有数字
www.example.fr/drive/cat.productlist.pagination_0.topage/2?t:ac=3686962/3686315
第二个:
www.example.com/some/cat.productlist.pagination_0.topage/4?t:ac=someText
我怎么知道我的输入是第一个还是第二个?
我试过这个:
myURL = http://www.example.com/some/cat.productlist.pagination_0.topage/4?t:ac=someText
parsed_url = urlparse.urlparse(myURL)
number2, number3 = urlparse.parse_qs(parsed_url.query)["t:ac"][0].split("/")
if ( isinstance( number2, numbers.Number) and isinstance( number3, numbers.Number) ) :
print "first"
else :
print "second"