Urllib2 抓取网页元素然后反转它

Urllib2 grab web-page element then reverse it

我需要拜访http://www.chiquitooenterprise.com/ reverse the string and access the website using this URL: http://www.chiquitooenterprise.com/password?code=REVERSEDSTRING

我如何使用 urllib2 和 Python 执行此操作?


link = "http://www.chiquitooenterprise.com/password"
request = urllib2.Request("http://www.chiquitooenterprise.com/password")
contents = urllib2.urlopen(request).read()

revString = request[::-1]
answer = "http://www.chiquitooenterprise.com/password?code=" + revString
response = urllib2.urlopen(answer)
response = response.read()
print(response)```
link = "http://www.chiquitooenterprise.com/password"
result = requests.get("http://www.chiquitooenterprise.com/password")
contents = result.text

revString = contents[::-1]
answer = f"http://www.chiquitooenterprise.com/password?code={revString}" 
response = requests.get(answer)
response = response.text
print(response)