This is the output of the code now
So here is my code now:
import requests
from bs4 import BeautifulSoup
import time
from docx import Document
def linkgenerator_getlink():
link = "https://attack.mitre.org/techniques/"
for i in range(1001, 1200):
fullurl = link + "T" + str(i) + "/"
source = requests.get(fullurl).text
time.sleep(15)
soup = BeautifulSoup(source, 'lxml')
document = Document()
document.add_heading(soup.find('h1').text.strip().encode("UTF-8"), 0)
description = soup.find('div',attrs={"class":"col-md-8 description-body"})
desc_1 = document.add_paragraph(description.text)
document.add_heading('Examples', level=2)
examples = soup.find('tbody',attrs={"class":"bg-white"})
for s in examples:
run = document.add_paragraph(s.text.strip())
document.add_heading('Mitigation', level=2)
mitigation = soup.find('h2', {'id':'mitigation'})
mitigation_1 =
document.add_paragraph(mitigation.find_next_sibling('p').text)
document.add_heading('Detection', level=2)
detection = soup.find('h2', {'id':'detection'})
detection_1 =
document.add_paragraph(detection.find_next_sibling('p').text)
document.save('C:\\Users\\horvathadamtamas\\Desktop\\script\\word-ok\\' + (str("T%s.docx") % str(i)))
print "========== %s-es szamu doksi is ready ==========" % i
linkgenerator_getlink()
My question is: In the line that starts with examples = soup.find... It puts the lines with too much spacing between the lines and the text size is now 11Pt and I want it smaller like 8Pt.
Thanks for the help guys! :)
Comments
Post a Comment