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

本站现有博文332篇,共被浏览897837

本站已经建立2598天!

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