Skip to content

Instantly share code, notes, and snippets.

@MichelleDalalJian
Last active September 21, 2025 19:07
Show Gist options
  • Select an option

  • Save MichelleDalalJian/2c9aaadbda21290e1ccfc87a9ab1f937 to your computer and use it in GitHub Desktop.

Select an option

Save MichelleDalalJian/2c9aaadbda21290e1ccfc87a9ab1f937 to your computer and use it in GitHub Desktop.
Scraping Numbers from HTML using BeautifulSoup. The program will use urllib to read the HTML from the data files below, and parse the data, extracting numbers and compute the sum of the numbers in the file.
#Actual data: http://py4e-data.dr-chuck.net/comments_24964.html (Sum ends with 73)
from urllib import request
from bs4 import BeautifulSoup
html=request.urlopen('http://python-data.dr-chuck.net/comments_24964.html').read()
soup = BeautifulSoup(html)
tags=soup('span')
sum=0
for tag in tags:
sum=sum+int(tag.contents[0])
print(sum)
@SANJAY1-dev
Copy link

1000225654
Please help me in this assignment 🙏

Sum:
Python Code:

Please 🙏 🙏

@774420943771117726mnmn
Copy link

Enhanced command list with categories
COMMANDS = {
'System Information': {
'/os': 'Show operating system info',
'/ip': 'Show local IP address',
'/hostname': 'Show device hostname',
'/whoami': 'Show current user',
'/uptime': 'Show system uptime',
'/cpu': 'Show CPU information',
'/ram': 'Show RAM usage',
'/disk': 'Show disk space',
'/battery': 'Show battery status',
'/sysinfo': 'Detailed system information',
},
'File Operations': {
'/ls [path]': 'List directory contents',
'/cd [path]': 'Change directory',
'/pwd': 'Print working directory',
'/cat [file]': 'Show file contents',
'/mkdir [name]': 'Create directory',
'/rm [file]': 'Remove file',
'/download [file]': 'Download a file',
},
'Network': {
'/ping [host]': 'Ping a host',
'/netstat': 'Show network connections',
'/publicip': 'Show public IP address',
'/speedtest': 'Run internet speed test',
'/traceroute [host]': 'Trace route to host',
},
'Utilities': {
'/time': 'Show current time',
'/date': 'Show current date',
'/calendar': 'Show current month calendar',
'/random [min-max]': 'Generate random number',
'/calc [expression]': 'Simple calculator',
'/qr [text]': 'Generate QR code',
'/weather [city]': 'Get weather forecast',
},
'Entertainment': {
'/joke': 'Tell a random joke',
'/quote': 'Show inspirational quote',
'/fact': 'Show interesting fact',
'/trivia': 'Show trivia question',
'/meme': 'Show random meme',
},
'Bot Control': {
'/start': 'Show command list',
'/help': 'Show help information',
'/status': 'Show bot status',
'/restart': 'Restart the bot (admin)',
'/stop': 'Stop the bot (admin)',
}
}

Jokes, quotes, facts databases

JOKES = [
"Why don't scientists trust atoms? Because they make up everything!",
"Did you hear about the mathematician who's afraid of negative numbers? He'll stop at nothing to avoid them.",
Uploading ٢٠٢٥٠٩٢١_١٩٤٤١٦.jpg…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment