[英]How to get the Specific Data from Spedific Positions from a List of Items?
I am scraping a Website, where I am trying to get the
Location
,Graduation
,Job type
andSalary
seperately so that I can use it later.我正在抓取一个网站,我试图分别获取Location
、Graduation
、Job type
和Salary
,以便我以后可以使用它。
This is the Code:这是代码:
r2 = requests.get(link, headers = headers)
soup2 = BeautifulSoup(r2.content, 'lxml')
locationPTag = soup2.find_all('p', class_= 'card-meta')
for k in locationPTag:
getLocation = k.text.strip()
print(getLocation)
here the
link
is: https://www.karmasandhan.com/public-service-commission-west-bengal-wbpsc-assistant-engineer-jobs-advt-no-21-2020/40261这里的link
是: https://www.karmasandhan.com/public-service-commission-west-bengal-wbpsc-assistant-engineer-jobs-advt-no-21-2020/40261
Output received is: Output 收到的是:
West Bengal, Multiple Cities
Engineering Diploma/ Degree
Regular
15600 — 42000
This is a Single Item.这是一个单一的项目。 How can I separate all of them to separate Variables so as to use them individually?如何将它们全部分离为单独的变量以便单独使用它们?
Try this:尝试这个:
r2 = requests.get(link, headers = headers)
soup2 = BeautifulSoup(r2.content, 'lxml')
locationPTag = soup2.find_all('p', class_= 'card-meta')
Location, Graduation, Job_type, Salary = [k.text.strip() for k in locationPTag]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.