EADST

Extract Webpage Information with Python

Here is the python program to extract webpage information with BeautifulSoup and save the data in a CSV file.

from bs4 import BeautifulSoup
import urllib.request
import pandas as pd

url = 'file:///Users/xd/Desktop/ieee/Region_5_Student_Branch_Counselors_and_Chairs.htm'
save_file = 'ieee_info_1'
html = urllib.request.urlopen(url).read()

soup = BeautifulSoup(html, "html.parser")

universities = soup.find_all('div', class_='spoName bullet pad-t15')
people = soup.find_all('div', class_='roster-results')

for u, p in zip(universities, people):
    info = p.find_all('p')
    university = u.get_text()
    name = info[0].get_text()
    if name == 'Position Vacant':
        continue
    title = info[2].get_text()
    address = info[3].get_text() + ', ' + info[4].get_text()
    email = info[-1].get_text()[7:]

    content = [[university, name, title, address, email]]
    list_name = ['university', 'name', 'title', 'address', 'email']
    data = pd.DataFrame(columns=list_name, data=content)
    data.to_csv("{}.csv".format(save_file), mode='a', index=False, header=False, encoding='utf-8')
About Me
XD
Goals determine what you are going to be.
Category
标签云
llama.cpp SQL Use Clash Pandas Hungarian FP8 LLM Food Nginx printf CLAP 阿里云 Windows Website API Dataset Harness DeepSeek Image2Text C++ 继承 Docker Attention Github Jetson Bin Linux DeepStream Ubuntu transformers Ptyhon PyCharm Data 图标 Vim Domain Input Crawler JSON RL XML Hotel RGB 财报 TSV Vmess VSCode GGML TensorFlow BF16 PIP tar Logo 音频 Translation Safetensors 公式 Land 腾讯云 TTS HuggingFace hf 签证 TensorRT Zip Gemma Qwen2 Anaconda LLAMA 报税 NLTK Math Search Review 图形思考法 FP16 Interview API网关 Claude Paper Datetime Bipartite COCO Git Jupyter Card ms-swift Qwen PDF Paddle Color GoogLeNet 关于博主 CTC Proxy SAM v2ray Bitcoin OpenCV NameSilo FastAPI uwsgi Markdown CV Tiktoken GIT 论文 Pillow IndexTTS2 CAM 第一性原理 Michelin PDB Numpy 域名 FlashAttention Template WAN git Password GPT4 Quantize FP64 Bert ResNet-50 CUDA Hilton OCR Animate Tracking BTC 云服务器 Diagram Excel VGG-16 UNIX 算法题 Rebuttal 长期记忆 Magnet Baidu Agent 顶会 v0.dev EXCEL SQLite ONNX ChatGPT torchinfo InvalidArgumentError Permission Algorithm ModelScope SVR Mixtral Random FP32 Freesound Python git-lfs GPTQ Statistics SPIE WebCrawler Web Plotly VPN LaTeX Quantization Pytorch Cloudreve XGBoost 强化学习 自我改进 Sklearn Miniforge Shortcut Heatmap Base64 scipy LeetCode Google 搞笑 Firewall 递归学习法 icon Conda LoRA Llama Qwen2.5 Streamlit diffusers Transformers PyTorch Distillation Disk Jev UI CEIR OpenAI 多线程 Knowledge Plate YOLO Pickle Augmentation RAR MD5 mmap AI logger CC Django uWSGI Tensor HaggingFace tqdm 多进程 Video NLP 论文速读 版权 净利润 飞书 Breakpoint News BeautifulSoup 证件照 QWEN CSV
站点统计

本站现有博文339篇,共被浏览998429次

本站已经建立2709天!

热门文章
文章归档
回到顶部