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

本站现有博文338篇,共被浏览976533次

本站已经建立2689天!

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