Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # coding: utf-8
- from __future__ import unicode_literals
- import wikipedia as wp
- def add_section_info(search):
- table_of_contents = []
- dict_of_section_info = {}
- toc = wp.page(search).sections
- for item in toc:
- section = wp.page(search).section(item)
- if section == "":
- continue
- else:
- dict_of_section_info[item] = section
- with open("Section_Info.txt",'a') as sect:
- sect.write(search)
- sect.write("\n---------------------------------------------------------------------------\n")
- for item in dict_of_section_info:
- print item.encode("UTF-8")
- print dict_of_section_info[item].encode("UTF-8")
- sect.write(item.encode("UTF-8"))
- sect.write("\n\n")
- sect.write(dict_of_section_info[item].encode("UTF-8"))
- sect.write("\n")
- sect.write("##############################################################\n\n")
- with open("exactMatches.txt",'r') as f:
- for line in f:
- add_section_info(line)
Advertisement
Add Comment
Please, Sign In to add comment