0

We're taking over another company's website and we plan on creating an archived version of their old site using wget to mirror the site into an archive.example.com website.

Since there are several year's worth of articles and stories and a considerable amount of stories still in Google, we are planning on 301'ing as many of the urls as we can and replacing their old defunct ad code with new DFP tags.

Any thoughts on how to replace thousands of old JS ad tags in a directory full of static html pages?

closed as primarily opinion-based by Simon Hayter Jun 4 '18 at 20:42

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Sorry but this question is opinionated as there are many ways that this can be done. – Simon Hayter Jun 4 '18 at 20:43
  • Example: powershell, ssh, editors (notepad+, sublime, brackets) httrack, SFTP clients, FTP clients... All answers would be correct based on your question, hence opinionated, all are right, some are better than others, subjectively. – Simon Hayter Jun 4 '18 at 20:50
  • 1
    Just because there can be multiple answers doesn't mean it's opinion. The answers themselves either work or do not work. Answers to this question can in fact be answered through facts, references or specific expertise. – Dan Gayle Jun 4 '18 at 20:50
  • It should also be noted that while the question has a 'website' feel to it, it's actually more of an operating system/application since find and replace is no different on an HTML file than it is to a CVS or TXT file. You will most likely find related questions on SuperUser or if you require variables (regex) then Stack Overflow. – Simon Hayter Jun 4 '18 at 21:29
3

Some text editors, including Notepad++, have a "find in files" search and replace option. You tell it what directory to search, what string to search for (can be regex or just plain text), and what to replace it with (if anything). This would work on a local copy which you'd then need to upload. You might want to replace it with simple Google Tag Manager code, which would then allow you to manage all the scripts from one dashboard (change in one place, it changes everywhere) so you don't have to go through this again.

If you have SSH access to the server, you could also (after backing up) run a command to search and replace across files.

In either case it's more complicated if the code is not exactly the same from page to page - i.e. sometimes it's indented, other times not, sometimes multi-line, which is where the regex options may come in quite handy.

  • The original website is on a terrible hosted solution, so I don't think I have access to pre-edit the ad code. You're right though, it would be a great way to handle it otherwise. – Dan Gayle Jun 4 '18 at 20:41
  • Your using wget yet you have no access? ... perfectly good answer based on your question. – Simon Hayter Jun 4 '18 at 20:45
  • Do you even know what wget is? – Dan Gayle Jun 4 '18 at 20:51
  • Yes? Why wouldn't you have access to these files? since you obviously have command line access on the external server. Then... you just sshfs (SFTP) or FTP mount the drive on your workstation and use Notepad++ as advised. As I said a perfectly good answer and one of many that can be provided, none more right than the next. An opinionated question as an I said previously, but thank you for attempting to make me look stupid with the wget comment. – Simon Hayter Jun 4 '18 at 21:07
  • I am using WGET to grab an external website that I have limited control over. Your question was "You're using wget yet you have no access," the answer to which is yes, I am using wget BECAUSE I have no access. Not trying to make you look stupid. But your concept of opinion as regards to proper questions and answers is flawed. There are slots here for multiple answers. Multiple different answers to the same question is a good and helpful thing, none of which have to be opinion based answers. Just factual answers. How do I do this, here are X number of ways. No opinions necessary or wanted. – Dan Gayle Jun 4 '18 at 21:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.