python learning tutorial, guess the number game development

python learning tutorial, guess the number game development

Click the blue word "python tutorial" to follow us!

Guess the Numbers (also known as Bulls and Cows) is an ancient code-breaking puzzle game that originated in the middle of the 20th century. It is generally played by two or more people, and it can also be played by one person and a computer.

Source code display:

import webbrowser as web
import re
import urllib
import time
import os
def spider(url,urlpattern):
    urls=getURLs(url,urlpattern)
    for url in urls:
        visitURL(url)
def visitURL(url):
    url=url[:-1] #remove the "at the end of the string
    print(url)
    #print("\n")    
    web.open(url,1,False)
    time.sleep(5)
def getURLs(url,urlpattern):
    urls=[]

    response=urllib.urlopen(url)
    html=response.read()
    pattern=re.compile(urlpattern)
    urls=pattern.findall(html)
    urls=list(set(urls))
    return urls


if __name__=="__main__":
    urls={
        "Fill in the address of your blog here"
        }
    for i in range(1,10):
        for url,urlpattern in urls.items():
            spider(url,urlpattern)
        print("Blogs has been refreshed for ", i, "times")
        os.system("taskkill/F/IM chrome.exe")

There is not a lot of code, don't copy, practice more!

Precautions

01

Students who are interested in Python development technology, welcome to join the communication group below to learn together and discuss with each other.

02

If you don’t understand in the process of learning python, you can join my python zero-base system to learn and exchange Qiuqiu qun: 934109170, to share with you the current talent needs of Python companies and how to learn Python from a zero-base, and what to learn. Related learning video materials and development tools are shared

Alright! The article is shared with the readers here

Finally, if you find it helpful, remember to follow, forward, and favorite

Reference: https://cloud.tencent.com/developer/article/1460812 python learning tutorial, guess the number game development-Cloud + Community-Tencent Cloud