goscrape

package module
v0.0.0-...-2d9c5bd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2015 License: MIT Imports: 8 Imported by: 3 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

GoScrape GoDoc Build Status

It scrapes udp trackers

Usage

Get the package

go get github.com/Stephen304/goscrape

Then import it

import ("github.com/Stephen304/goscrape")

Then create a bulk scraper

scraper := NewBulk([]string{
  "udp://tracker.example.com:80",
  "udp://tracker.example2.com:80"})

Then lets scrape some stuff

result := scraper.ScrapeBulk([]string{
  "40Character-BitTorrent-Info-Hash-Is-Here",
  "40Character-BitTorrent-Info-Hash-Is-Here",
  "40Character-BitTorrent-Info-Hash-Is-Here",
})

What did we get?

for _, one := range result {
  fmt.Println(one)
}

{40Character-BitTorrent-Info-Hash-Is-Here 17281 5105 304430}
{40Character-BitTorrent-Info-Hash-Is-Here 11169 7439 70603}
{40Character-BitTorrent-Info-Hash-Is-Here 7252 2745 93562}

Documentation

Overview

Package goscrape provides useful methods to scrape UDP trackers.

Goscrape may be used to scrape a single tracker for many torrents, multiple trackers for a single torrent, or a single tracker for a single torrent.

It provides 2 ways to do this:

Bulk: The preferred method allows you to reuse connections to repeatedly scrape the same tracker(s) to save reconnection time.

Single: A method for one-off scraping. It doesn't preserve the connection, so it will reconnect every time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bulk

type Bulk struct {
	Sess   []Session
	Expire time.Time
}

Bulk stores multiple sessions and keeps track of when to refresh the connection ID.

func NewBulk

func NewBulk(trackers []string) Bulk

NewBulk creates a new bulk object for running multiple scrapes on the same set of trackers without recreating a new connection each time.

func (*Bulk) ScrapeBulk

func (bulk *Bulk) ScrapeBulk(btihs []string) []Result

ScrapeBulk scrapes a set of info hashes from the connections the bulk was initialized with.

type Result

type Result struct {
	Btih      string
	Seeders   int
	Leechers  int
	Completed int
}

Result represents the scrape result for a single torrent. It includes the 40 character base64 bit torrent info hash, Seeders, Leechers, and Completed counts.

func Single

func Single(urls []string, btihs []string) []Result

Single scrapes 1 or more trackers for 1 or more torrents. It doesn't save the connection.

type Session

type Session struct {
	Conn   *net.UDPConn
	ConnID uint64
	URL    string
}

Session stores the details of a single tracker session. This includes the connection object, the connection ID, and the URL to use for reconnecting.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL