C++基本概念之动态联编与静态联编

一个简单的获取数独题目的python脚本

皮贝贝 posted @ 2010年11月15日 15:47 in 岁月舍利 with tags python sudoku , 6062 阅读

       现在很多网站都是在线题库的形式提供, 可以利用网页交互来获取相应的题目。简化了本地程序生成题目策略。比如 http://www.suduko.us/j/smallcn.php 这个网站提供了一个比较全的题目, 有难度分级,共 50000 个题目, 分为5个级别(1~5),每个级别为连续的10000个题目。先给个这个网站的数独玩的界面:

>

 

       例如, 如果要获取难度级别为2的一个题目:

http://www.suduko.us/j/smallcn.php?nd=2

       获取题号为 38888 的题目:

http://www.suduko.us/j/smallcn.php?xh=38888

       获得网页内容后, 可以通过正则式子来获取获得的题目信息, 返回的信息比较全:题目,答案,级别,题号。 这是获取 38888 得到的一段网页内容:

    		var tmda;
    		tmda='010000820000090000020070030034008000000002000005000009000000080000000000709050000913645827478293651526871934234918576197562348865437219651729483342186795789354162210001';
        document.getElementById('tm').value  =  tmda.substring(0,81); 
        document.getElementById('da').value  =  tmda.substring(81,162); 
        document.getElementById('nd').value  =  tmda.substring(162,163); 
        document.getElementById('tmxh').value = tmda.substring(163,170); 

       搜索 "tmda" 字符串只出现在这里。 利用 re.compile ('tmda=\'(.*?)\';') 得到这一串。

def getTmByXh(xh):
    url = "http://www.suduko.us/j/smallcn.php?xh=" + str(xh)

   # get web
    webdata = urlopen (url).read()

    # get 
    sudoku_subject = re.compile ('tmda=\'(.*?)\';')
    m = sudoku_subject.findall (webdata)
    if m:
        print m[0]
    else:
        print 'not find tm by xh: ', xh

 

  • 无匹配
Avatar_small
maids in dubai 说:
2021年9月06日 17:08

The written agreement French Maid costume is however amongst the most common choice, and it's found in many numerous styles for just anyone to get yourself a perfect in good shape. While Halloween usually is the point in time when most of our fantasies - just like maid an individual - come to life, these fancy dress are perfect for a bit of fun actually of the age. Surprise the man to you when he returns from work to look for you carrying out a little brightness housework from a sexy maid costume - shipment must do the housework for longer!

Avatar_small
monthly maid service 说:
2023年10月17日 17:32

his is the main the main hiring procedure as money is important for both, you and the maid or the cleaning service, so discuss this matter very clearly. Try not to be too generous in excitement, as you have to consider your finances also. In the long run it can cause problems for you and also don't be very rigid also, as you may lose a good maid or cleaning service.

Avatar_small
boardmodelpaper.com 说:
2024年1月26日 02:18

Board Model Papers 2024 provide all states of 6th to 10th text books 2024 Candidates who are Searching for 6th to 10th and 11th to 12th text books and syllabus, sample questions, exam pattern, and Co-Curricular Subject textbooks can refer to this entire article. boardmodelpaper.com and question papers for following the website and Arts, Science, Commerce Stream Subject Wise Solved Question Bank for Hindi & English Medium Students with Exam Pattern & Blueprint and subject Wise with 11th & 12th Question Bank 2024 for General & Vocational Course. Here, we have gathered all subjects of Board textbooks for all Class along with the direct download links.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter