我想做一次大学项目。如何调整此代码以仅检索某些字段,如名字,姓氏,标题等。下面打印整页的完整刮痕。
Linkedin Scraper Code在这里CODE
require 'linkedin-scraper'
myfile = File.new("LinkedIn2.txt", "w+")
profile_names =[LinkedinProfile1, LinkedinProfile2]
profiles = profile_names.map do |profile|
Linkedin::Profile.get_profile(profile)
end
myfile.puts(profiles.to_s)
答案 0 :(得分:0)
只需尝试将它们导出为CSV格式,请使用以下内容:
require 'linkedin-scraper'
require 'csv'
CSV.open('profiles.csv', 'wb') do |csv|
profile_names =[LinkedinProfile1, LinkedinProfile2]
profile_names.each do |profile_name|
profile = Linkedin::Profile.get_profile(profile_name)
csv << [profile.first_name, profile.last_name]
end
end
然后,您可以在Excel或Numbers中打开CSV文件进行查看或更新。
答案 1 :(得分:0)
从您发布的链接:
profile.first_name # The first name of the contact
profile.last_name # The last name of the contact
profile.name # The full name of the profile
profile.title # The job title
profile.summary # The summary of the profile
profile.location # The location of the contact
profile.country # The country of the contact
profile.industry # The domain for which the contact belongs
profile.picture # The profile picture link of profile
profile.skills # Array of skills of the profile
profile.organizations # Array organizations of the profile
profile.education # Array of hashes for education
profile.websites # Array of websites
profile.groups # Array of groups
profile.languages # Array of languages
profile.certifications # Array of certifications
您的代码将变为:(例如)
require 'linkedin-scraper'
myfile = File.new("LinkedIn2.txt", "w+")
profile_names =[LinkedinProfile1, LinkedinProfile2]
profiles = profile_names.map do |profile|
Linkedin::Profile.get_profile(profile).title
end
myfile.puts(profiles.to_s)