Write a python function that accepts single page's html code as an input, tries to find…
- User
Write a python function that accepts single page's html code as an input, tries to find it there is a steam store app id mentioned somewhere in the text, and returns this app id, it it's true, or returns 0 if there isn't
Assistant
Here's a Python function to extract a Steam app ID from HTML content:
import re def extract_steam_app_id(html_content): # Common patterns for Steam app IDs in HTML patterns = [ r'store\.steampowered\.com/app/(\d+)', # URLs r'steam_app_id["\s:=]+(\d+)', # Meta tags or JS variables r'app[/_-](\d+)', # Various formats r'steamapp[/_-](\d+)', # Various formats r'AppId["\s:=]+(\d+)', # JS or meta variables r'data-steam-id="(\d+)"' # Data attributes ] for pattern in patterns: matches = re.findall(pattern, html_content, re.IGNORECASE) if matches: return int(matches[0]) return 0Would you like me to explain or break down this code?
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.