- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
import requests
from bs4 import BeautifulSoup
import pandas as pd
baseurl='https://signal.nfx.com/'
headers ={
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36'
}
r =requests.get('https://signal.nfx.com/investor-lists/top-who-invested-in-female-founders-investors')
soup=BeautifulSoup(r.content, 'html.parser')
tra = soup.find_all('div',class_='pr3')
productlinks=[]
p=[]
u=[]
for links in tra:
for link in links.find_all('a',href=True):
comp=baseurl+link['href']
productlinks.append(comp)
for link in productlinks:
r =requests.get(link,headers=headers)
soup=BeautifulSoup(r.content, 'html.parser')
try:
address=soup.find('span',class_='ml1').text
except:
address=''
p.append(address)
try:
link=soup.find('a',class_='ml1 subheader lower-subheader').text
except:
link=''
u.append(link)
df = pd.DataFrame(
{"address": p, "link": u}
)
print(df)
这是我的输出,只给我一个 address
和 link
然后他们将打印 empty list
并完成任务你能帮忙吗找到所有地址和链接我试图从页面中抓取数据但他们不会提供页面的完整信息这些是我抓取信息的链接 https://signal.nfx.com/investors/aaleen-anjum
address link
0 Toronto, Ontario twosmallfish.vc
1
2
3
4
5
6
7
8
9
10
11
最佳答案
可以通过api获取数据。例如,这里是投资者:
import requests
import pandas as pd
url= "https://signal-api.nfx.com/graphql"
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36'}
payload = {"operationName":"vclInvestors",
"variables":{"slug":"who-invested-in-female-founders",
"order":[{}],
"after":""},
"query":"query vclInvestors($slug: String!, $after: String) {\n list(slug: $slug) {\n id\n slug\n investor_count\n vertical {\n id\n display_name\n kind\n __typename\n }\n location {\n id\n display_name\n __typename\n }\n stage\n firms {\n id\n name\n slug\n __typename\n }\n scored_investors(first: 8, after: $after) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n endCursor\n __typename\n }\n record_count\n edges {\n node {\n ...investorListInvestorProfileFields\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n}\n\nfragment investorListInvestorProfileFields on InvestorProfile {\n id\n person {\n id\n first_name\n last_name\n name\n slug\n is_me\n is_on_target_list\n __typename\n }\n image_urls\n position\n min_investment\n max_investment\n target_investment\n is_preferred_coinvestor\n firm {\n id\n name\n slug\n __typename\n }\n investment_locations {\n id\n display_name\n location_investor_list {\n id\n slug\n __typename\n }\n __typename\n }\n investor_lists {\n id\n stage_name\n slug\n vertical {\n id\n display_name\n __typename\n }\n __typename\n }\n __typename\n}\n"}
results = pd.DataFrame()
hasNextPage = True
after = ''
while hasNextPage == True:
payload['variables']['after'] == after
jsonData = requests.post(url, headers=headers, json=payload ).json()
data = jsonData['data']['list']['scored_investors']['edges']
df = pd.json_normalize(data)
results = results.append(df, sort=False).reset_index(drop=True)
count = len(results)
tot = jsonData['data']['list']['investor_count']
print(f'{count} of {tot}')
hasNextPage = jsonData['data']['list']['scored_investors']['pageInfo']['hasNextPage']
after = jsonData['data']['list']['scored_investors']['pageInfo']['endCursor']
输出:
print(results.head(2).to_string())
__typename node.__typename node.id node.person.id node.person.first_name node.person.last_name node.person.name node.person.slug node.person.is_me node.person.is_on_target_list node.person.__typename node.image_urls node.position node.min_investment node.max_investment node.target_investment node.is_preferred_coinvestor node.firm.id node.firm.name node.firm.slug node.firm.__typename node.investment_locations node.investor_lists node.firm
0 InvestorProfileEdge InvestorProfile 19676 87099 Aaleen Anjum Aaleen Anjum aaleen-anjum False False Person [https://signal-api.nfx.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBMWp2QVE9PSIsImV4cCI6bnVsbCwicHVyIjoiYmxvYl9pZCJ9fQ==--1dc8054880c588f1fd59361ebd5d8526f841049d/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBPZ2hxY0djNkUzSmxjMmw2WlY5MGIxOW1hV3hzV3dkcEFsZ0NhUUpZQWc9PSIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--f8e22238db523e6e5e5a8ae643921849c4b207bd/0, https://signal-api.nfx.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBMW52QVE9PSIsImV4cCI6bnVsbCwicHVyIjoiYmxvYl9pZCJ9fQ==--df77fc9ad679d550ce8e2472e47150cb9fc610e6/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBPZ2hxY0djNkUzSmxjMmw2WlY5MGIxOW1hV3hzV3dkcEFsZ0NhUUpZQWc9PSIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--f8e22238db523e6e5e5a8ae643921849c4b207bd/1, https://signal-api.nfx.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBMXJ2QVE9PSIsImV4cCI6bnVsbCwicHVyIjoiYmxvYl9pZCJ9fQ==--1f58605b9a843b9ee1e820d63d154aea24936f84/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBPZ2hxY0djNkUzSmxjMmw2WlY5MGIxOW1hV3hzV3dkcEFsZ0NhUUpZQWc9PSIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--f8e22238db523e6e5e5a8ae643921849c4b207bd/2, https://signal-api.nfx.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBMXZ2QVE9PSIsImV4cCI6bnVsbCwicHVyIjoiYmxvYl9pZCJ9fQ==--2a200a001411bbff92bd9deb68b4a54215ee0863/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBPZ2hxY0djNkUzSmxjMmw2WlY5MGIxOW1hV3hzV3dkcEFsZ0NhUUpZQWc9PSIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--f8e22238db523e6e5e5a8ae643921849c4b207bd/3] analyst 150000 1000000 250000 False 4445 Two Small Fish Ventures two-small-fish-ventures Firm [] [{'id': '6141', 'stage_name': 'Pre-Seed', 'slug': 'ai-pre-seed', 'vertical': {'id': '3', 'display_name': 'AI', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '3', 'stage_name': 'Seed', 'slug': 'ai-seed', 'vertical': {'id': '3', 'display_name': 'AI', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '6144', 'stage_name': 'Pre-Seed', 'slug': 'blockchain-pre-seed', 'vertical': {'id': '7', 'display_name': 'Blockchain', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '7', 'stage_name': 'Seed', 'slug': 'blockchain-seed', 'vertical': {'id': '7', 'display_name': 'Blockchain', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '5406', 'stage_name': 'Other Lists', 'slug': 'british-columbia', 'vertical': {'id': '9678', 'display_name': 'British Columbia', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '6169', 'stage_name': 'Pre-Seed', 'slug': 'consumer-health-pre-seed', 'vertical': {'id': '11', 'display_name': 'Consumer Health', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '11', 'stage_name': 'Seed', 'slug': 'consumer-health-seed', 'vertical': {'id': '11', 'display_name': 'Consumer Health', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '6145', 'stage_name': 'Pre-Seed', 'slug': 'cryptocurrency-pre-seed', 'vertical': {'id': '13', 'display_name': 'Cryptocurrency', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '13', 'stage_name': 'Seed', 'slug': 'cryptocurrency-seed', 'vertical': {'id': '13', 'display_name': 'Cryptocurrency', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '6203', 'stage_name': 'Pre-Seed', 'slug': 'cybersecurity-pre-seed', 'vertical': {'id': '57799', 'display_name': 'Cybersecurity', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '5554', 'stage_name': 'Seed', 'slug': 'cybersecurity-seed', 'vertical': {'id': '57799', 'display_name': 'Cybersecurity', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '6172', 'stage_name': 'Pre-Seed', 'slug': 'developer-tools-pre-seed', 'vertical': {'id': '15', 'display_name': 'Developer Tools', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '15', 'stage_name': 'Seed', 'slug': 'developer-tools-seed', 'vertical': {'id': '15', 'display_name': 'Developer Tools', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '6205', 'stage_name': 'Pre-Seed', 'slug': 'digital-health-pre-seed', 'vertical': {'id': '57801', 'display_name': 'Digital Health', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '5644', 'stage_name': 'Seed', 'slug': 'digital-health-seed', 'vertical': {'id': '57801', 'display_name': 'Digital Health', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '6207', 'stage_name': 'Pre-Seed', 'slug': 'direct-to-consumer-dtc-pre-seed', 'vertical': {'id': '57803', 'display_name': 'Direct-to-Consumer (DTC)', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '5734', 'stage_name': 'Seed', 'slug': 'direct-to-consumer-dtc-seed', 'vertical': {'id': '57803', 'display_name': 'Direct-to-Consumer (DTC)', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '171', 'stage_name': 'Other Lists', 'slug': 'diverse', 'vertical': {'id': '24242', 'display_name': 'Diverse Investors', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '6148', 'stage_name': 'Pre-Seed', 'slug': 'enterprise-pre-seed', 'vertical': {'id': '20', 'display_name': 'Enterprise', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '20', 'stage_name': 'Seed', 'slug': 'enterprise-seed', 'vertical': {'id': '20', 'display_name': 'Enterprise', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '172', 'stage_name': 'Other Lists', 'slug': 'female', 'vertical': {'id': '24241', 'display_name': 'Female Investors', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '6162', 'stage_name': 'Pre-Seed', 'slug': 'saas-pre-seed', 'vertical': {'id': '48', 'display_name': 'SaaS', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '47', 'stage_name': 'Seed', 'slug': 'saas-seed', 'vertical': {'id': '48', 'display_name': 'SaaS', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '169', 'stage_name': 'Other Lists', 'slug': 'who-invested-in-diverse-founders', 'vertical': {'id': '24244', 'display_name': 'Investors who invested in diverse founders', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '170', 'stage_name': 'Other Lists', 'slug': 'who-invested-in-female-founders', 'vertical': {'id': '24243', 'display_name': 'Investors who invested in female founders', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '187', 'stage_name': 'Other Lists', 'slug': 'who-were-founders', 'vertical': {'id': '24387', 'display_name': 'Investors who were founders', '__typename': 'Tag'}, '__typename': 'InvestorList'}] NaN
1 InvestorProfileEdge InvestorProfile 13187 29548 Aamir Virani Aamir Virani aamir-virani False False Person [https://signal-api.nfx.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBeTJHQVE9PSIsImV4cCI6bnVsbCwicHVyIjoiYmxvYl9pZCJ9fQ==--a7cd75f799cb3eb96a06cbd6b67d287971185953/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBPZ2hxY0djNkUzSmxjMmw2WlY5MGIxOW1hV3hzV3dkcEFsZ0NhUUpZQWc9PSIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--f8e22238db523e6e5e5a8ae643921849c4b207bd/0] angel 1 100000 25000 False NaN NaN NaN NaN [{'id': '7500', 'display_name': 'California', 'location_investor_list': None, '__typename': 'Tag'}, {'id': '7502', 'display_name': 'Texas', 'location_investor_list': None, '__typename': 'Tag'}, {'id': '7498', 'display_name': 'United States', 'location_investor_list': None, '__typename': 'Tag'}] [{'id': '6141', 'stage_name': 'Pre-Seed', 'slug': 'ai-pre-seed', 'vertical': {'id': '3', 'display_name': 'AI', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '3', 'stage_name': 'Seed', 'slug': 'ai-seed', 'vertical': {'id': '3', 'display_name': 'AI', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '6170', 'stage_name': 'Pre-Seed', 'slug': 'consumer-internet-pre-seed', 'vertical': {'id': '12', 'display_name': 'Consumer Internet', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '12', 'stage_name': 'Seed', 'slug': 'consumer-internet-seed', 'vertical': {'id': '12', 'display_name': 'Consumer Internet', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '6152', 'stage_name': 'Pre-Seed', 'slug': 'hardware-pre-seed', 'vertical': {'id': '28', 'display_name': 'Hardware', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '28', 'stage_name': 'Seed', 'slug': 'hardware-seed', 'vertical': {'id': '28', 'display_name': 'Hardware', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '6156', 'stage_name': 'Pre-Seed', 'slug': 'iot-pre-seed', 'vertical': {'id': '34', 'display_name': 'IoT', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '33', 'stage_name': 'Seed', 'slug': 'iot-seed', 'vertical': {'id': '34', 'display_name': 'IoT', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '6179', 'stage_name': 'Pre-Seed', 'slug': 'local-services-pre-seed', 'vertical': {'id': '35', 'display_name': 'Local Services', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '34', 'stage_name': 'Seed', 'slug': 'local-services-seed', 'vertical': {'id': '35', 'display_name': 'Local Services', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '6185', 'stage_name': 'Pre-Seed', 'slug': 'parenting-families-pre-seed', 'vertical': {'id': '43', 'display_name': 'Parenting/Families', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '42', 'stage_name': 'Seed', 'slug': 'parenting-families-seed', 'vertical': {'id': '43', 'display_name': 'Parenting/Families', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '6199', 'stage_name': 'Pre-Seed', 'slug': 'real-estate-proptech-pre-seed', 'vertical': {'id': '45', 'display_name': 'Real Estate/PropTech', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '44', 'stage_name': 'Seed', 'slug': 'real-estate-proptech-seed', 'vertical': {'id': '45', 'display_name': 'Real Estate/PropTech', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '6161', 'stage_name': 'Pre-Seed', 'slug': 'robotics-pre-seed', 'vertical': {'id': '47', 'display_name': 'Robotics', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '46', 'stage_name': 'Seed', 'slug': 'robotics-seed', 'vertical': {'id': '47', 'display_name': 'Robotics', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '6162', 'stage_name': 'Pre-Seed', 'slug': 'saas-pre-seed', 'vertical': {'id': '48', 'display_name': 'SaaS', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '47', 'stage_name': 'Seed', 'slug': 'saas-seed', 'vertical': {'id': '48', 'display_name': 'SaaS', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '188', 'stage_name': 'Other Lists', 'slug': 'san-francisco-bay-area', 'vertical': {'id': '22992', 'display_name': 'San Francisco Bay Area', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '6187', 'stage_name': 'Pre-Seed', 'slug': 'smb-software-pre-seed', 'vertical': {'id': '51', 'display_name': 'SMB Software', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '50', 'stage_name': 'Seed', 'slug': 'smb-software-seed', 'vertical': {'id': '51', 'display_name': 'SMB Software', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '169', 'stage_name': 'Other Lists', 'slug': 'who-invested-in-diverse-founders', 'vertical': {'id': '24244', 'display_name': 'Investors who invested in diverse founders', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '170', 'stage_name': 'Other Lists', 'slug': 'who-invested-in-female-founders', 'vertical': {'id': '24243', 'display_name': 'Investors who invested in female founders', '__typename': 'Tag'}, '__typename': 'InvestorList'}, {'id': '187', 'stage_name': 'Other Lists', 'slug': 'who-were-founders', 'vertical': {'id': '24387', 'display_name': 'Investors who were founders', '__typename': 'Tag'}, '__typename': 'InvestorList'}] NaN
关于python - 如何使用 beautifulsoup 从页面中抓取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69866449/
我需要将文本放在 中在一个 Div 中,在另一个 Div 中,在另一个 Div 中。所以这是它的样子: #document Change PIN
奇怪的事情发生了。 我有一个基本的 html 代码。 html,头部, body 。(因为我收到了一些反对票,这里是完整的代码) 这是我的CSS: html { backgroun
我正在尝试将 Assets 中的一组图像加载到 UICollectionview 中存在的 ImageView 中,但每当我运行应用程序时它都会显示错误。而且也没有显示图像。 我在ViewDidLoa
我需要根据带参数的 perl 脚本的输出更改一些环境变量。在 tcsh 中,我可以使用别名命令来评估 perl 脚本的输出。 tcsh: alias setsdk 'eval `/localhome/
我使用 Windows 身份验证创建了一个新的 Blazor(服务器端)应用程序,并使用 IIS Express 运行它。它将显示一条消息“Hello Domain\User!”来自右上方的以下 Ra
这是我的方法 void login(Event event);我想知道 Kotlin 中应该如何 最佳答案 在 Kotlin 中通配符运算符是 * 。它指示编译器它是未知的,但一旦知道,就不会有其他类
看下面的代码 for story in book if story.title.length < 140 - var story
我正在尝试用 C 语言学习字符串处理。我写了一个程序,它存储了一些音乐轨道,并帮助用户检查他/她想到的歌曲是否存在于存储的轨道中。这是通过要求用户输入一串字符来完成的。然后程序使用 strstr()
我正在学习 sscanf 并遇到如下格式字符串: sscanf("%[^:]:%[^*=]%*[*=]%n",a,b,&c); 我理解 %[^:] 部分意味着扫描直到遇到 ':' 并将其分配给 a。:
def char_check(x,y): if (str(x) in y or x.find(y) > -1) or (str(y) in x or y.find(x) > -1):
我有一种情况,我想将文本文件中的现有行包含到一个新 block 中。 line 1 line 2 line in block line 3 line 4 应该变成 line 1 line 2 line
我有一个新项目,我正在尝试设置 Django 调试工具栏。首先,我尝试了快速设置,它只涉及将 'debug_toolbar' 添加到我的已安装应用程序列表中。有了这个,当我转到我的根 URL 时,调试
在 Matlab 中,如果我有一个函数 f,例如签名是 f(a,b,c),我可以创建一个只有一个变量 b 的函数,它将使用固定的 a=a1 和 c=c1 调用 f: g = @(b) f(a1, b,
我不明白为什么 ForEach 中的元素之间有多余的垂直间距在 VStack 里面在 ScrollView 里面使用 GeometryReader 时渲染自定义水平分隔线。 Scrol
我想知道,是否有关于何时使用 session 和 cookie 的指南或最佳实践? 什么应该和什么不应该存储在其中?谢谢! 最佳答案 这些文档很好地了解了 session cookie 的安全问题以及
我在 scipy/numpy 中有一个 Nx3 矩阵,我想用它制作一个 3 维条形图,其中 X 轴和 Y 轴由矩阵的第一列和第二列的值、高度确定每个条形的 是矩阵中的第三列,条形的数量由 N 确定。
假设我用两种不同的方式初始化信号量 sem_init(&randomsem,0,1) sem_init(&randomsem,0,0) 现在, sem_wait(&randomsem) 在这两种情况下
我怀疑该值如何存储在“WORD”中,因为 PStr 包含实际输出。? 既然Pstr中存储的是小写到大写的字母,那么在printf中如何将其给出为“WORD”。有人可以吗?解释一下? #include
我有一个 3x3 数组: var my_array = [[0,1,2], [3,4,5], [6,7,8]]; 并想获得它的第一个 2
我意识到您可以使用如下方式轻松检查焦点: var hasFocus = true; $(window).blur(function(){ hasFocus = false; }); $(win
我是一名优秀的程序员,十分优秀!