ten$1 发表于 2020-7-16 20:35:43

爬虫 - 找一串数字的规律

import requests
import bs4
import sys

s = input("输入数列: ")
#s = "1,2,3,6,11,23,47,106,235"
res = requests.get("http://oeis.org/search?q=" + s + "&sort=&language=english&go=Search")
res.text

soup = bs4.BeautifulSoup(res.text, "html.parser")
titles = soup.find("td", align = "left", valign = "top").contents
strt = str(titles)
for x in range(9, len(strt) + 1):
    if strt == 'v' and strt == 'a' and strt == 'l' and strt == 'i' and strt == 'g'and strt == 'n':
      if strt == 'f':
            print("规律为")
            for y in range(x + 8, len(strt) + 1):
                if strt == '<':
                  print("自行翻译成中文~")
                  sys.exit(0)
                print(strt, end="")


爬得网站是 http://oeis.org
就是有点慢
页: [1]
查看完整版本: 爬虫 - 找一串数字的规律