-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
55 lines (43 loc) · 1.67 KB
/
test.py
File metadata and controls
55 lines (43 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# from langchain_community.document_loaders.html_bs import BSHTMLLoader
# headers = {
# "User-Agent": "My User Agent 1.1",
# "From": "[email protected]",
# }
# # response = requests.get(
# # url="https://www.sec.gov/Archives/edgar/data/320193/000032019323000106/aapl-20230930.htm",
# # headers=headers,
# # )
# # if response.status_code == 200:
# # # Get the text (HTML) from the response
# # html_content = response.text
# # # Open a file named 'content.html' in write mode ('w')
# # with open("content.html", "w", encoding="utf-8") as file:
# # # Write the HTML content to the file
# # file.write(html_content)
# # print("Content saved to 'content.html'.")
# # else:
# # print(
# # f"Failed to retrieve the website content. Status code: {response.status_code}"
# # )
# import requests
# from bs4 import BeautifulSoup
# # URL of the webpage
# url = "https://www.sec.gov/Archives/edgar/data/320193/000032019323000106/aapl-20230930.htm"
# # Send a GET request to the URL
# response = requests.get(url, headers=headers)
# # Check if the request was successful
# if response.status_code == 200:
# # Use BeautifulSoup to parse the HTML content
# soup = BeautifulSoup(response.text, "html.parser")
# # Write the parsed HTML to a local file
# with open("content.html", "w", encoding="utf-8") as file:
# file.write(str(soup.prettify()))
# print("HTML content saved successfully.")
# else:
# print(f"Failed to retrieve the webpage: Status code {response.status_code}")
# loader = BSHTMLLoader("content.html")
# data = loader.load()
# print(data)
import os
apikey = os.environ("OPENAI_API_KEY")
print(apikey)