小编Boc*_*cui的帖子

使用tkinter输入变量,进行调用

我目前正在开发一种刮刀程序,它将进入一个维基百科页面,并以其当前形式,将从页面中删除引用.

我想要一个允许用户输入维基百科页面的gui.我希望输入附加到selectWikiPage变量,但到目前为止没有运气.

以下是我目前的代码.

import requests
from bs4 import BeautifulSoup
import re
from tkinter import *

#begin tkinter gui
def show_entry_fields():
   print("Wikipedia URL: %s" % (e1.get()))
   e1.delete(0,END)
master = Tk()
Label(master, text="Wikipedia URL").grid(row=0)
e1 = Entry(master)
e1.insert(10,"http://en.wikipedia.org/wiki/randomness")
e1.grid(row=0, column=1)
Button(master, text='Scrape', command=master.quit).grid(row=3, column=0, sticky=W, pady=4)
mainloop( )

session = requests.Session()
selectWikiPage = input(print("Please enter the Wikipedia page you wish to scrape from"))
if "wikipedia" in selectWikiPage:
    html = session.post(selectWikiPage)
    bsObj = BeautifulSoup(html.text, "html.parser")

    findReferences = bsObj.find('ol', {'class': 'references'}) #isolate …
Run Code Online (Sandbox Code Playgroud)

python tkinter python-3.x python-3.5 tkinter-entry

13
推荐指数
2
解决办法
901
查看次数

按字母顺序排序文本文件(Python)

我想按字母顺序对文件'shopping.txt'进行排序

shopping = open('shopping.txt')
line=shopping.readline()
while len(line)!=0:
    print(line, end ='')
    line=shopping.readline()
#for eachline in myFile:
#    print(eachline)
shopping.close()
Run Code Online (Sandbox Code Playgroud)

python sorting

11
推荐指数
3
解决办法
6万
查看次数