Skip to content

[WIP] A library for scraping listings off facebook marketplace

License

Notifications You must be signed in to change notification settings

drinklilt/fb-mktplc-scraper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Facebook Marketplace Scraper

[WIP] A library for scraping listings off facebook marketplace

Synopsis

A library (written in golang) for pulling listings from facebook marketplace. It uses chromedriver and selenium to find listings and pull the relevant data from each, routing them into a nice channel that can be pulled infinitely (in theory).

Usage

Make sure you already have chrome driver running

service, err := selenium.NewChromeDriverService("chromedriver", 4444)
if err != nil {
	log.Fatal("Error:", err)
}
// Technically this shouldn't be deferred because Stop() can return an error
defer service.Stop()

Create capabilities of the driver you are about to pass to the web driver

caps := selenium.Capabilities{}
caps.AddChrome(chrome.Capabilities{Args: []string{
	"--headless",
}})

Make a new instance of the scraper and start it providing a context

scraper, err := NewInstance(&caps)
if err != nil {
	panic(err)
}

ctx, cancel := context.WithCancel(context.Background())

scraper.Start(ctx)

Now you can pull products from the channel in the scraper struct

// This will give you one of the listings
listing := <-scraper.Products
fmt.Println(listing.Name)

Future

The list of features that I want to add

  • Specify the town / city
  • Specify the search criteria
  • Specify category
  • Specify min price and max price
  • Navigate to /marketplace/item/{id} and get extra information

About

[WIP] A library for scraping listings off facebook marketplace

Resources

License

Stars

Watchers

Forks

Languages