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

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

本站已经建立2713天!

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