【发布时间】:2020-09-04 20:34:59
【问题描述】:
import requests
from bs4 import BeautifulSoup
import pandas as pd
start_url="https://www.indeed.co.in/jobs?q=teacher&l=India"
page_data=requests.get(start_url)
soup=BeautifulSoup(page_data.content,"html.parser")
Title=[]
Company=[]
Salary=[]
Summary=[]
Location=[]
link_to_apply=[]
for job_tag in soup.find_all("div",class_="jobsearch-SerpJobCard unifiedRow row result"):
title=job_tag.find("h2",class_="title")
company=job_tag.find("span",class_="company")
location=job_tag.find(class_="location accessible-contrast-color-location").text.strip()
summary=job_tag.find("div",class_="summary")
link=job_tag.find("a",href=True)
base_url="https://www.indeed.com"
final_link=base_url+link["href"]
Title.append(title.text.strip())
Company.append(company.text.strip())
Location.append(location)
Summary.append(summary.text.strip())
link_to_apply.append(final_link)
data=list(zip(Title,Company,Location,Summary))
p=pd.DataFrame(data,columns=["Title","Company","Location","Summary"])
p.to_csv("new.csv")
pd.set_option("display.max_colwidth",None)
pd.set_option("display.max_rows",None)
pd.set_option("display.max_rows",None)
pd.set_option("display.width",None)
pd.set_option('display.max_columns',None)
the output of the following code
Title \
0 all Subject Teacher\nnew
1 Part time Teacher / Trainer
2 Online Tutor / Teachers - Women Candidates only - Non Metro...\nnew
3 Science & Maths Teacher\nnew
4 Primary School Teacher
5 Preschool Teacher\nnew
6 Online Tutor / Teachers - Women Candidates only- Across Indi...
7 Maths Teacher
8 wanted faculty for teaching cbse school
9 Primary English Teacher
10 Training Facilitator
11 Head Teacher
12 Math Teacher\nnew
13 Teacher for Kids
14 Preschool Teacher - Vizag
Company \
0 Home Guru
1 Home Guru
2 Whitehat Education Technology Pvt. Ltd.
3 Home Guru
4 Newdimension International School
5 Home Guru
6 Whitehat Education Technology Pvt. Ltd.
7 Dheeraj International School
8 TILFORD SCHOOL,JANGAREDDIGUDEM,W.G.DIST,ANDHRA PRA...
9 Stones2Milestones
10 Stones2Milestones
11 Wunderschool
12 GEMS Public School,Patiala
13 ANAR EdTech
14 Koala Preschool
Location \
0 Remote
1 Remote
2 Kochi, Kerala
3 Remote
4 Bhongir, Andhra Pradesh
5 Mumbai, Maharashtra
6 Bengaluru, Karnataka
7 Pune, Maharashtra
8 Jangareddi Gudem Bazar, Andhra Pradesh
9 Gurgaon, Haryana
10 Gurgaon, Haryana
11 Chandigarh, Chandigarh
12 Univ P O Patiala, Punjab
13 Kochi, Kerala
14 Visakhapatnam, Andhra Pradesh
Summary
0 We are recognized leaders in one to one coaching of all subjects & Courses, both online and offline.\nStudents and Gurus from all across India are invited to get…
1 We are recognized leaders in one to one coaching of all subjects & Courses, both online and offline.\nStudents and Gurus from all across India are invited to get…
2 Teacher, Work from Home, Online Tutor, Teaching, Home Tutor, coding teacher, computer teacher, home teacher, kids teacher.\nYou've found your dream job.
3 We are recognized leaders in one to one coaching of all subjects & Courses, both online and offline.\nStudents and Gurus from all across India are invited to get…
4 Proven experience as a teacher.\nCollaborate with other teachers, parents and stakeholders and participate in regular meetings.\nTotal work: 1 year (Preferred).
5 We Provide Virtual recorded sessions of Preschool curriculum,.\nHave to record Virtual Classes of preschool curriculum.\nMust have preschool teaching experience.
6 Teacher, Work from Home, Online Tutor, Teaching, Home Tutor, coding teacher, computer teacher, home teacher, kids teacher.\nYou've found your dream job.
7 We are looking for qualified and experienced candidates who can join immediately for the following posts at Dheeraj International School, Pune.
8 WANTED FACULTY FOR TEACHING @CBSE SCHOOL.\nSalary not constraint for deserving candidates. *.\nSalary: Up to ₹50,000.00 per month.
9 We are looking to bring into our fold an incredible teacher/facilitator to conduct online classes for children of ages 6-10.\nWorking with: Consumer App Team.
10 We are looking to bring into our fold an incredible teacher/facilitator to conduct online classes for children of ages 6-10.\nWorking with: Consumer App Team*.
11 The Head teacher shall influence the thinking and practice of students, teachers and parents.\nPlanning, Documentation , Evaluation, Mentorship, Guidance and…
12 Welcome to Gems Public School, Patiala...\nGEMS is an international education company.\nIt is a global advisory and educational management firm, with a network of…
13 We are* looking for dynamic and vibrant lady tutors with a passion for inspiring our kids to flourish and reach their potentials.\nWork at your convenient time.
14 Our growing Preschool facility is looking for a Young energetic Female Preschool Teacher who can help to create a fun environment and incorporate educational…
我希望输出位于适当的表格列中。此外,表格需要保存到 CSV 文件 这就是我选择熊猫的原因。请快速回复,谢谢大家 有人知道为什么我没有得到正确的数据框吗?大熊猫作为输出 还有其他方法吗? 同样在创建的 csv 文件中,输出正常,但在 python 中却不是
【问题讨论】:
-
还看到一些数据被截断,即它的到来告诉我一种解决方法
-
Pandas 不适合花哨的输出。在 Excel 中打开 CSV 文件,使其看起来适合您。
-
@DYZ 看到数据在 csv 文件中作为正确的表格列正确出现,但是当我在 python 中显示它时它没有出现,并且 pandas 仅在正常 python 空闲时输出有问题..我是使用 jupyter 笔记本!
标签: python-3.x pandas dataframe web-scraping python-requests