How to get the SMILES of all compounds on PubChem?
The best way to download bulk data from PubChem is actually FTP, as documented in their documentation.

For example, if you want the unfiltered SMILES of every CID in PubChem, the URL is ftp://ftp.ncbi.nlm.nih.gov/pubchem/Compound/Extras/CID-SMILES.gz

You can also download subsets using the PubChem Structure Download service

And as mentioned above, there are Python and other tools to access both PubChem and ChemSpider through their documented web APIs.