benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf 8416b635-43a2-5bc8-b0a2-a199025f7bc1
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import requests
from bs4 import BeautifulSoup
def task_func(url, tag):
"""
Scrape a web page for the first occurrence of a specified HTML tag and return its text content.
Parameters:
url (str): The URL of the website to scrape.
tag (str): The HTML tag to find and retrieve text from.
Returns:
str: The text content of the specified HTML tag if found, otherwise returns None.
Requirements:
- requests
- bs4.BeautifulSoup
Example:
>>> task_func("https://www.google.com/", "title")
'Google'
"""
instruct prompt
Scrape a web page for the first occurrence of a specified HTML tag and return its text content.
The function should output with:
str: The text content of the specified HTML tag if found, otherwise returns None.
You should write self-contained code starting with:
Code
import requests
from bs4 import BeautifulSoup
def task_func(url, tag):
code prompt
Code
import requests
from bs4 import BeautifulSoup
def task_func(url, tag):
entry point
task_func
libs
- bs4
- requests
Discussion
No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.
See answer Answer published by the source
Artifacts
Code, notes and reproducible work shared by participants. Files are served from a separate origin.
No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.
Source and history
initial import