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

本站现有博文340篇,共被浏览1019261次

本站已经建立2719天!

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