Guest User

bs4_request_4

a guest
Mar 27th, 2020
62
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. import requests
  3. from bs4 import BeautifulSoup
  4. import csv
  5.  
  6.  
  7. def Main(url):
  8. r = requests.get(url)
  9. soup = BeautifulSoup(r.content, 'html.parser')
  10. name = soup.find("div", class_="detailSection corporationName").get_text(
  11. strip=True, separator=" ")
  12. data = [item.string for item in soup.select(
  13. "div.detailSection.filingInformation span")]
  14. del data[5]
  15. # print(data[2:-2])
  16. with open("data.csv", 'w', newline="") as f:
  17. writer = csv.writer(f)
  18. writer.writerow(["Name", "Document Number",
  19. "FEI/EIN Number", "Date Filed", "Status", "Last Event"])
  20. writer.writerow([name, *data[2:-2]])
  21.  
  22.  
  23. Main("http://search.sunbiz.org/Inquiry/CorporationSearch/SearchResultDetail?inquirytype=EntityName&directionType=Initial&searchNameOrder=A%201421260&aggregateId=domp-142126-360258c3-c08b-4f9a-8866-ad3ecdedef02&searchTerm=A&listNameOrder=A%201421260")
  24.  
  25. output:
  26.  
  27. File "/home/martin/dev/python/sunbiz_org.py", line 19
  28. writer.writerow([name, *data[2:-2]])
  29. ^
  30. SyntaxError: invalid syntax
  31. [Finished in 0.437s]
RAW Paste Data