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

本站现有博文333篇,共被浏览918249

本站已经建立2623天!

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