我正在尝试获取Google搜索中的第一个URL。就像我在Google上搜索“ tcs”一样,它给出了http://www.tcs.com/。 大多数情况下结果是正确的,但有时我没有获得正确的URL。我想要一个解决方案。 在Google搜索上尝试以下操作:-“ Euler Baubetr。u。Bauleitungsges。mbH” 结果即将到来:-https://www.firmenwissen.com/.../EULER_BAUBETREUUNG_UND_ BAULEITUNGSGESELLSCHAFT_MBH.html
中间的输出URL中的即将到来
import requests
from bs4 import BeautifulSoup as bs
var="Euler Baubetr. u. Bauleitungsges. mbH"
goog_search = "https://www.google.co.uk/search?sclient=psyab&client=ubuntu&hs=k5b&channel=fs&biw=1366&bih=648&noj=1&q=" + var
r = requests.get(goog_search)
soup = bs(r.text, "html.parser")
url=soup.find('cite').text
print(url)
答案 0 :(得分:0)
您应该浏览正确的href以获取网址,请参见下面的代码...
func createCloud () {
for i in 0...3 {
let background = SKSpriteNode(imageNamed: "test")
background.name = "Test"
background.size = CGSize(width: frame.size.width, height:
frame.size.height * 2)
background.zPosition = 0
// background.position = CGPoint(x: -(self.frame.size.width), y: CGFloat(i) * background.size.height)
self.addChild(background)
}
}
func moveCloud () {
self.enumerateChildNodes(withName: "Test", using: ({ (node, error) in
node.position.y -= 2
if node.position.y < -((self.scene?.size.width)!) {
node.position.y += ( self.scene?.size.width)! * 3
}
}))
}