|
Download code/appdev-0015.jsonl from winapiadmin/tinycodinglm: direct link, hf CLI and curl.
- Browser
- Download file 2.25 kB
-
https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/7fe6853bcbe998c7aec3aa0f7086f584cc091586/code/appdev-0015.jsonl
- Command line
-
hf download hf://datasets/winapiadmin/tinycodinglm@7fe6853bcbe998c7aec3aa0f7086f584cc091586/code/appdev-0015.jsonl
-
curl -L -o appdev-0015.jsonl https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/7fe6853bcbe998c7aec3aa0f7086f584cc091586/code/appdev-0015.jsonl
2.25 kB
| {"type": "session", "harness": "opencode", "id": "appdev-0015", "name": "web scraper"} | |
| {"type": "message", "message": {"role": "system", "content": "You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing code, identify bugs, security issues, and performance problems. You have deep knowledge of C/C++, Windows API, Python, and many other technologies."}} | |
| {"type": "message", "message": {"role": "user", "content": "Walk me through building a web scraper: key concepts, concrete details and common pitfalls. Include a runnable code example with its expected output."}} | |
| {"type": "message", "message": {"role": "assistant", "content": "**Web Scraper** (using requests + BeautifulSoup):\n\n```python\nimport requests\nfrom bs4 import BeautifulSoup\nimport json\nimport time\n\ndef scrape_hn(top_n=30):\n \"\"\"Scrape Hacker News front page.\"\"\"\n url = 'https://news.ycombinator.com/'\n resp = requests.get(url, headers={'User-Agent': 'Mozilla/5.0'})\n soup = BeautifulSoup(resp.text, 'html.parser')\n\n articles = []\n for item in soup.select('.titleline > a')[:top_n]:\n articles.append({\n 'title': item.get_text(),\n 'url': item.get('href', ''),\n })\n return articles\n\ndef scrape_with_retry(url, max_retries=3):\n \"\"\"Scrape with retry logic.\"\"\"\n for attempt in range(max_retries):\n try:\n resp = requests.get(url, timeout=10)\n resp.raise_for_status()\n return BeautifulSoup(resp.text, 'html.parser')\n except requests.RequestException as e:\n print(f'Attempt {attempt+1} failed: {e}')\n time.sleep(2 ** attempt)\n return None\n\nif __name__ == '__main__':\n articles = scrape_hn()\n for i, a in enumerate(articles, 1):\n print(f'{i}. {a[\"title\"]}')\n print(f' {a[\"url\"]}\\n')\n with open('hn_articles.json', 'w') as f:\n json.dump(articles, f, indent=2)\n```\n\n**Best practices:**\n- Respect robots.txt\n- Add delays between requests\n- Handle errors gracefully\n- Cache responses when possible"}} | |