2種類のURLがあります
最初のものはURLの最後に数字があります
www.example.fr/drive/cat.productlist.pagination_0.topage/2?t:ac=3686962/3686315
2番目のもの:
www.example.com/some/cat.productlist.pagination_0.topage/4?t:ac=someText
自分の入力が 1 つ目または 2 つ目のようなものであることをどのように知ることができますか?
私はこれを試しました:
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"