Write cleaned HTML or a CSV of links under /uploads. After Run, click ↓ on the file chip.
Goal
Save clean.html and links.csv from a small soup.
HTML file
import os
html = """
<html><body>
<li class="sold-out">Samosa</li>
<li>Chai</li>
</body></html>
"""
soup = BeautifulSoup(html, "html.parser")
soup.select_one(".sold-out").decompose()
with open("clean.html", "w") as f:
f.write(str(soup))
print("uploads:", os.listdir("/uploads"))
print(open("clean.html").read())Links CSV
import os
html = """
<nav>
<a href="/nairobi/">Nairobi</a>
<a href="/mombasa/">Mombasa</a>
<a href="/kisumu/">Kisumu</a>
</nav>
"""
soup = BeautifulSoup(html, "html.parser")
df = pd.DataFrame(
[
{"text": a.get_text(strip=True), "href": a.get("href")}
for a in soup.find_all("a")
]
)
df.to_csv("links.csv", index=False)
print(df)
print("uploads:", os.listdir("/uploads"))Tip
Use a bare filename such as links.csv. The upload helper writes it into /uploads.