We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
加了一个output
def open_webbrowser_count(question,choices): print('\n -- 题目+选项搜索结果计数法 -- Question:' + question + '\n') #print('Question: ' + question + '\n') if '不是' in question: print('请注意此题为否定题,选计数最少的')
counts = [] for i in range(len(choices)): # 请求 req = requests.get(url='http://www.baidu.com/s', params={'wd': question + choices[i]}) content = req.text index = content.find('百度为您找到相关结果约') + 11 content = content[index:] index = content.find('个') count = content[:index].replace(',', '') counts.append(count) #print(choices[i] + " : " + count) #print("\033[0;31m{0:^10}:{1:^10}\033[0m".format(choices[i],count)) #print(counts) output(choices, counts)
def count_base(question,choices): print('\n -- 题目搜索结果包含选项词频计数法 -- Question:' + question + '\n') # 请求 req = requests.get(url='http://www.baidu.com/s', params={'wd':question}) content = req.text #print(content) counts = [] #print('Question: ' + question + '\n') if '不是' in question: print('请注意此题为否定题,选计数最少的') for i in range(len(choices)): counts.append(content.count(choices[i])) #print((choices[i], + " : " + str(counts[i])) #print("\033[0;31m{0:^10}:{1:^10}\033[0m".format(choices[i], str(counts[i]))) output(choices, counts)
def output(choices, counts): counts = list(map(int, counts)) #print(choices, counts)
# 最可能的答案 index_max = counts.index(max(counts)) # 最不可能的答案 index_min = counts.index(min(counts)) if index_max == index_min: print("\033[1;31m此方法失效!\033[0m") return for i in range(len(choices)): if i == index_max: # 绿色为最可能的答案 print("\033[1;32m{0:^10} {1:^10}\033[0m".format(choices[i], counts[i])) elif i == index_min: # 红色为最不可能的答案 print("\033[0;31m{0:^10}{1:^10}\033[0m".format(choices[i], counts[i])) else: print("{0:^10} {1:^10}".format(choices[i], counts[i]))
The text was updated successfully, but these errors were encountered:
觉得流程需要优化,现在执行步骤太多,搜索结果解析速度太慢了,跟不上真题节奏
Sorry, something went wrong.
@heishanmao 谢谢,最大最小结果可能有重复,我之前就没写了,看一眼也差不多,更新的代码已采用
@asseywang 可尝试最新代码
No branches or pull requests
加了一个output
def open_webbrowser_count(question,choices):
print('\n -- 题目+选项搜索结果计数法 -- Question:' + question + '\n')
#print('Question: ' + question + '\n')
if '不是' in question:
print('请注意此题为否定题,选计数最少的')
def count_base(question,choices):
print('\n -- 题目搜索结果包含选项词频计数法 -- Question:' + question + '\n')
# 请求
req = requests.get(url='http://www.baidu.com/s', params={'wd':question})
content = req.text
#print(content)
counts = []
#print('Question: ' + question + '\n')
if '不是' in question:
print('请注意此题为否定题,选计数最少的')
for i in range(len(choices)):
counts.append(content.count(choices[i]))
#print((choices[i], + " : " + str(counts[i]))
#print("\033[0;31m{0:^10}:{1:^10}\033[0m".format(choices[i], str(counts[i])))
output(choices, counts)
def output(choices, counts):
counts = list(map(int, counts))
#print(choices, counts)
The text was updated successfully, but these errors were encountered: