(Instagram)Scrape所有Facebook places_id在一个没有访问令牌的区域

时间:2017-09-22 20:28:35

标签: json facebook facebook-graph-api web-scraping instagram-api

如何在布鲁克林找到所有的facebook_places_id?我需要他们来抓住Instagram的公共网站。

我可以按名称查找place_id的单个位置。我有位置ID后,我还可以查询所有照片/视频和元数据。所有这些都是可用的,无需访问令牌。

查找facebook_places_id&#39> s 此URL允许您按名称查找location_ids。例如,这将返回"布鲁克林,纽约和#34; (您可以将其输入任何浏览器并查看结果,无需访问密钥或登录。我建议使用Firefox):

https://www.instagram.com/web/search/topsearch/?context=place&query=brooklyn+new+york

从返回的JSON中,我们可以看到"布鲁克林,纽约"有facebook_places_id 212950988

抓取给定facebook_places_id的元数据

此网址将返回有关布鲁克林帖子的JSON元数据:

https://www.instagram.com/graphql/query/?query_id=17881432870018455&id=212950988&first=12&after=0"

如果我知道这个地方,我可以得到我想要的一切,我只需要一份完整的地方要求。

1 个答案:

答案 0 :(得分:0)

https://www.instagram.com/web/search/topsearch/?context=place&query=brooklyn+new+york

您从上述API调用获得的id不是facebook_places_id,而是您在API调用中使用的instagram_location_id来获取位置信息。

下面是Facebook Graph API调用,以获取由lat,lng和distance指定的一个城市或地区中的facebook_places_id。但是这需要一个facebook access_token

https://graph.facebook.com/search?q=coffee&type=place&center=45.5230622,-122.67648150000002&distance=5000&access_token=XXX

您可以获取facebook_places_id列表,然后使用以下API调用获取相应的instagram_location_id,您可以使用该https://api.instagram.com/v1/locations/search?facebook_places_id=694471784029871&access_token=XXX 获取位置信息数据。

access_token

此API调用需要Instagram import Foundation import UIKit let topViewHeight: CGFloat = 250 class SplitViewController: UIViewController, BottomViewControllerScrollDelegate { let topViewController: TopViewController = TopViewController() let bottomViewController: BottomViewController = BottomViewController() override func viewDidLoad() { super.viewDidLoad() automaticallyAdjustsScrollViewInsets = false bottomViewController.delegate = self addViewController(bottomViewController, frame: view.bounds, completion: nil) addViewController(topViewController, frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: topViewHeight), completion: nil) } func bottomViewScrollViewDidScroll(_ scrollView: UIScrollView) { print("\(scrollView.contentOffset.y)") let offset = (scrollView.contentOffset.y + topViewHeight) if offset < 0 { topViewController.view.frame.origin.y = 0 topViewController.view.frame.size.height = topViewHeight - offset } else { topViewController.view.frame.origin.y = -(scrollView.contentOffset.y + topViewHeight) topViewController.view.frame.size.height = topViewHeight } } } class TopViewController: UIViewController { let label = UILabel() override func viewDidLoad() { super.viewDidLoad() automaticallyAdjustsScrollViewInsets = false view.backgroundColor = UIColor.red label.text = "Top View" view.addSubview(label) } override func viewWillLayoutSubviews() { super.viewWillLayoutSubviews() label.sizeToFit() label.center = view.center } } protocol BottomViewControllerScrollDelegate: class { func bottomViewScrollViewDidScroll(_ scrollView: UIScrollView) } class BottomViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout { var collectionView: UICollectionView! weak var delegate: BottomViewControllerScrollDelegate? let cellPadding: CGFloat = 5 override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = UIColor.yellow automaticallyAdjustsScrollViewInsets = false let layout = UICollectionViewFlowLayout() layout.minimumInteritemSpacing = cellPadding layout.minimumLineSpacing = cellPadding layout.scrollDirection = .vertical layout.sectionInset = UIEdgeInsets(top: cellPadding, left: 0, bottom: cellPadding, right: 0) collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: layout) collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight] collectionView.contentInset.top = topViewHeight collectionView.scrollIndicatorInsets.top = topViewHeight collectionView.alwaysBounceVertical = true collectionView.backgroundColor = .clear collectionView.dataSource = self collectionView.delegate = self collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: String(describing: UICollectionViewCell.self)) view.addSubview(collectionView) } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return 30 } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: UICollectionViewCell.self), for: indexPath) cell.backgroundColor = UIColor.darkGray return cell } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { let width = floor((collectionView.frame.size.width - 2 * cellPadding) / 3) return CGSize(width: width, height: width) } func scrollViewDidScroll(_ scrollView: UIScrollView) { delegate?.bottomViewScrollViewDidScroll(scrollView) } } extension UIViewController { func addViewController(_ viewController: UIViewController, frame: CGRect, completion: (()-> Void)?) { viewController.willMove(toParentViewController: self) viewController.beginAppearanceTransition(true, animated: false) addChildViewController(viewController) viewController.view.frame = frame viewController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(viewController.view) viewController.didMove(toParentViewController: self) viewController.endAppearanceTransition() completion?() } }