|
|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
import requests
|
|
|
|
|
from lxml import etree
|
|
|
|
|
|
|
|
|
|
import time
|
|
|
|
|
base_url = 'https://www.runoob.com/python/python-exercise-example%s.html'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -20,7 +20,7 @@ def write_py(i, text):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
for i in range(1, 10):
|
|
|
|
|
for i in range(1, 101):
|
|
|
|
|
html = get_element(base_url % i)
|
|
|
|
|
content = '题目:' + html.xpath('//div[@id="content"]/p[2]/text()')[0] + '\n'
|
|
|
|
|
fenxi = html.xpath('//div[@id="content"]/p[position()>=2]/text()')[0]
|
|
|
|
|
@ -28,6 +28,8 @@ def main():
|
|
|
|
|
haha = '"""\n' + content + fenxi + daima + '\n"""'
|
|
|
|
|
write_py(i, haha)
|
|
|
|
|
print(fenxi)
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
main()
|
|
|
|
|
|