Termux

without sqlite3, recursive, recursive count, backticks %a system-call cURL

terminal

pkg install ruby clang make binutils
pkg install pkg-config libxslt binutils # additional dependencies
gem install nokogiri --platform=ruby -- --use-system-libraries

gem install sqlite3

a13dlme.rb

require 'nokogiri'
require 'open-uri'
require 'sqlite3'

url = 'https://13dl.me/list/popular/'

SQL =<<EOS                                                                     
create table manga(
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    title text
    );
EOS

db = SQLite3::Database.open("13dlme.db")
db.execute(SQL)

def scrape(num,url,db) 
  begin
    html = URI.open(url).read
  rescue => error
    p error.message
  else
    doc = Nokogiri::HTML.parse(html)
    doc.css('a').each do |x|
      xx = x.attr('title')

      if xx && xx !='' &&  xx !='Home' && xx !='Popular Manga' && xx !='Next' then
        pag = /^Page/.match?("#{xx}")
        pr = /^Prev/.match?("#{xx}")
#        nex = /^Next/.match?("#{xx}")

        unless pag | pr then
          #link = x.attr('href')
          puts "#{xx}"
          db.execute("insert into manga(id,title) values( null,'#{xx}') ;")
        end

      end

    end
  end
end

threads = []

80.times do |xx|
  40.times do |x|
    num = (xx + 1)*(x + 1)
    ta_url = url + "?p=" + "#{num}"
    threads << Thread.new do
      scrape(num,ta_url,db)
    end
  end
  threads.each(&:join)

end

db.close
Edit
Pub: 23 May 2022 11:52 UTC
Edit: 26 May 2022 04:21 UTC
Views: 191